1[/ 2 Copyright 2010 Neil Groves 3 Distributed under the Boost Software License, Version 1.0. 4 (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5/] 6[section:sort sort] 7 8[heading Prototype] 9 10`` 11template<class RandomAccessRange> 12RandomAccessRange& sort(RandomAccessRange& rng); 13 14template<class RandomAccessRange> 15const RandomAccessRange& sort(const RandomAccessRange& rng); 16 17template<class RandomAccessRange, class BinaryPredicate> 18RandomAccessRange& sort(RandomAccessRange& rng, BinaryPredicate pred); 19 20template<class RandomAccessRange, class BinaryPredicate> 21const RandomAccessRange& sort(const RandomAccessRange& rng, BinaryPredicate pred); 22`` 23 24[heading Description] 25 26`sort` sorts the elements in `rng` into ascending order. `sort` is not guaranteed to be stable. Returns the sorted range. 27 28For versions of the `sort` function without a predicate, ascending order is defined by `operator<()` such that for all adjacent elements `[x,y]`, `y < x == false`. 29 30For versions of the `sort` function with a predicate, ascending order is defined by `pred` such that for all adjacent elements `[x,y]`, `pred(y, x) == false`. 31 32[heading Definition] 33 34Defined in the header file `boost/range/algorithm/sort.hpp` 35 36[heading Requirements] 37 38[*For versions of sort without a predicate:] 39 40* `RandomAccessRange` is a model of the __random_access_range__ Concept. 41* `RandomAccessRange` is mutable. 42* `RandomAccessRange`'s value type is a model of the `LessThanComparableConcept`. 43* The ordering relation on `RandomAccessRange`'s value type is a [*strict weak ordering], as defined in the `LessThanComparableConcept` requirements. 44 45[*For versions of sort with a predicate] 46 47* `RandomAccessRange` is a model of the __random_access_range__ Concept. 48* `RandomAccessRange` is mutable. 49* `BinaryPredicate` is a model of the `StrictWeakOrderingConcept`. 50* `RandomAccessRange`'s value type is convertible to both of `BinaryPredicate`'s argument types. 51 52[heading Complexity] 53 54`O(N log(N))` comparisons (both average and worst-case), where `N` is `distance(rng)`. 55 56[endsect] 57 58 59