Lecture overview -- Keyboard shortcut: 'u'  Previous page: Function objects -- Keyboard shortcut: 'p'  Next page: An example of for-each and function objects -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Alphabetic index  Help page about these notes  Course home    Templates and The Standard Library - slide 36 : 39

Using the sort algorithm

We reproduce an example program that uses the sort algorithm from cplusplus.com

template <class RandomAccessIterator>
  void sort (RandomAccessIterator first, RandomAccessIterator last);

template <class RandomAccessIterator, class Compare>
  void sort (RandomAccessIterator first, RandomAccessIterator last, Compare comp);
prog-1.cpp
Sorting a vector of integers.