Skip to content

Commit

Permalink
sort namespaces lexicographically
Browse files Browse the repository at this point in the history
  • Loading branch information
meirish committed Aug 20, 2019
1 parent 060a2df commit 6a45c4b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ui/app/lib/path-to-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export default function(paths) {
return accumulator;
}, []);


tree = tree.sort((a, b)=> a.localeCompare(b));
// after the reduction we're left with an array that contains
// strings that represent the longest branches
// we'll replace the dots in the paths, then expand the path
Expand Down
22 changes: 22 additions & 0 deletions ui/tests/unit/lib/path-to-tree-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,28 @@ module('Unit | Lib | path to tree', function() {
},
},
],
[
'sorting lexicographically',
['99', 'bat', 'bat/bird', 'animal/flying/birds', 'animal/walking/dogs', 'animal/walking/cats', '1/thing'],
{
1: {
thing: null,
},
99: null,
animal: {
flying: {
birds:null,
},
walking: {
cats: null,
dogs: null,
}
},
bat: {
bird: null
}
},
],
];

tests.forEach(function([name, input, expected]) {
Expand Down

0 comments on commit 6a45c4b

Please sign in to comment.