MCPcopy Create free account
hub / github.com/Snapchat/djinni / sort

Method sort

examples/handwritten-src/cpp/sort_items_impl.cpp:19–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17}
18
19void SortItemsImpl::sort(sort_order order, const ItemList & items) {
20 auto lines = items.items;
21 switch (order) {
22 case sort_order::ASCENDING: {
23 std::sort(lines.begin(), lines.end(), std::less<std::string>());
24 break;
25 }
26 case sort_order::DESCENDING: {
27 std::sort(lines.begin(), lines.end(), std::greater<std::string>());
28 break;
29 }
30 case sort_order::RANDOM: {
31 std::shuffle(lines.begin(), lines.end(), std::default_random_engine{});
32 break;
33 }
34 }
35
36 // Pass result to client interface
37 this->m_listener->update(ItemList(lines));
38}
39
40ItemList SortItems::run_sort(const ItemList & items) {
41 auto lines = items.items;

Callers

nothing calls this directly

Calls 3

sortFunction · 0.85
updateMethod · 0.65
ItemListInterface · 0.50

Tested by

no test coverage detected