-// ugh, c&p
-template<typename T> void
-vector_sort (vector<T> &v, int (*compare) (T const &, T const &),
- vsize lower=VPOS, vsize upper=VPOS)
-{
- if (lower == VPOS)
- {
- lower = 0;
- upper = v.size () - 1;
- }
- if (upper == VPOS || lower >= upper)
- return;
- swap (v[lower], v[(lower + upper) / 2]);
- vsize last = lower;
- for (vsize i = lower +1; i <= upper; i++)
- if (compare (v[i], v[lower]) < 0)
- swap (v[++last], v[i]);
- swap (v[lower], v[last]);
- vector_sort (v, compare, lower, last - 1);
- vector_sort (v, compare, last + 1, upper);