Skip to content

Commit 9d27d9e

Browse files
authored
Fix sorting of examples with global priority. (#54)
1 parent 6fdcf3b commit 9d27d9e

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/help-generator_.toit

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ class HelpGenerator:
322322
this-examples := command_.examples_.map: | example/Example | [example, path_]
323323
sub-examples := []
324324
add-global-examples_ command_ sub-examples --path=path_ --skip-first-level
325-
sub-examples.sort --in-place: | a/List b/List | a[0].global-priority - b[0].global-priority
325+
// Higher priority examples should come first.
326+
sub-examples.sort --in-place: | a/List b/List | b[0].global-priority.compare-to a[0].global-priority
326327

327328
all-examples := this-examples + sub-examples
328329
if all-examples.is-empty: return

tests/help_test.toit

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -769,17 +769,17 @@ test-examples:
769769
# Root example 2:
770770
root sub2
771771
772+
# Example 5:
773+
root sub2 global5
774+
775+
# Example 1:
776+
root sub global3
777+
772778
# Example 3:
773779
root sub global1
774780
775781
# Example 6:
776782
root sub2 global1
777-
778-
# Example 1:
779-
root sub global3
780-
781-
# Example 5:
782-
root sub2 global5
783783
"""
784784
actual = build-examples.call [cmd]
785785
expect-equals expected actual

0 commit comments

Comments
 (0)