- int i = left, j = right;
- unsigned int key;
- VAPictureH264 tmp;
-
- if (frame_idx) {
- key = ref[(left + right) / 2].frame_idx;
- partition(ref, frame_idx, key, ascending);
- } else {
- key = ref[(left + right) / 2].TopFieldOrderCnt;
- partition(ref, TopFieldOrderCnt, (signed int)key, ascending);
- }
-
- /* recursion */
- if (left < j)
- sort_one(ref, left, j, ascending, frame_idx);
-
- if (i < right)
- sort_one(ref, i, right, ascending, frame_idx);
-}
-
-static void sort_two(VAPictureH264 ref[], int left, int right, unsigned int key, unsigned int frame_idx,
- int partition_ascending, int list0_ascending, int list1_ascending)
-{
- int i = left, j = right;
- VAPictureH264 tmp;
-
- if (frame_idx) {
- partition(ref, frame_idx, key, partition_ascending);
- } else {
- partition(ref, TopFieldOrderCnt, (signed int)key, partition_ascending);
- }
-
-
- sort_one(ref, left, i-1, list0_ascending, frame_idx);
- sort_one(ref, j+1, right, list1_ascending, frame_idx);
+ T *middle = partition(begin, end, [&](const T &elem) { return less_than(elem, pivot); });
+ sort(begin, middle, [&](const T &a, const T &b) { return less_than(b, a); });
+ sort(middle, end, less_than);