diff options
author | Miodrag Milanović <mmicko@gmail.com> | 2020-02-28 07:42:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-28 07:42:34 +0100 |
commit | 7e54d2c3054be47c6ed336ec66162d790213bf10 (patch) | |
tree | 26f60a1980a64b755a76ac2b1724ccc70e7812b9 | |
parent | bb754441c8acf70f82c1862a214e74164a403dc1 (diff) | |
parent | 34cc1bd41f3d1ec67872f7862063d43f1c136711 (diff) | |
download | nextpnr-7e54d2c3054be47c6ed336ec66162d790213bf10.tar.gz nextpnr-7e54d2c3054be47c6ed336ec66162d790213bf10.tar.bz2 nextpnr-7e54d2c3054be47c6ed336ec66162d790213bf10.zip |
Merge pull request #402 from zyp/fix_sort
gui: Fix sorting order in TreeModel.
-rw-r--r-- | gui/treemodel.cc | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/gui/treemodel.cc b/gui/treemodel.cc index e300c74d..448c9794 100644 --- a/gui/treemodel.cc +++ b/gui/treemodel.cc @@ -97,12 +97,7 @@ void IdStringList::updateElements(Context *ctx, std::vector<IdString> elements) auto parts_a = alphaNumSplit(a->name()); auto parts_b = alphaNumSplit(b->name()); - // Short-circuit for different part count. - if (parts_a.size() != parts_b.size()) { - return parts_a.size() < parts_b.size(); - } - - for (size_t i = 0; i < parts_a.size(); i++) { + for (size_t i = 0; i < parts_a.size() && i < parts_b.size(); i++) { auto &part_a = parts_a.at(i); auto &part_b = parts_b.at(i); @@ -134,8 +129,8 @@ void IdStringList::updateElements(Context *ctx, std::vector<IdString> elements) return part_a < part_b; } - // Same string. - return false; + // One string is equal to or a subset of the other, compare length. + return parts_a.size() < parts_b.size(); }); } |