| 605 | } |
| 606 | |
| 607 | void sort() |
| 608 | { |
| 609 | if (sorted) |
| 610 | return; |
| 611 | |
| 612 | auto compare = [] (const void* a, const void* b) { |
| 613 | const Key& first(KeyOfValue::generate(*static_cast<const Value*>(a))); |
| 614 | const Key& second(KeyOfValue::generate(*static_cast<const Value*>(b))); |
| 615 | |
| 616 | if (Cmp::greaterThan(first, second)) |
| 617 | return 1; |
| 618 | if (Cmp::greaterThan(second, first)) |
| 619 | return -1; |
| 620 | |
| 621 | return 0; |
| 622 | }; |
| 623 | |
| 624 | qsort(this->begin(), this->getCount(), sizeof(Value), compare); |
| 625 | sorted = true; |
| 626 | } |
| 627 | |
| 628 | private: |
| 629 | int sortMode; |