Skip to content

Commit

Permalink
feat(tonality): improve compareTo sorting by note and mode (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
albertms10 committed Apr 9, 2023
1 parent c913953 commit 485284c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions lib/src/tonality/tonality.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ class Tonality implements Comparable<Tonality> {

@override
int compareTo(covariant Tonality other) => compareMultiple([
() => accidentals.compareTo(other.accidentals),
() => accidental.semitones.compareTo(other.accidental.semitones),
() => note.compareTo(other.note),
() => mode.name.compareTo(other.mode.name),
]);
}
4 changes: 2 additions & 2 deletions test/src/tonality/tonality_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ void main() {
]);
expect(orderedSet.toList(), [
const Tonality(Note.c, Modes.major),
const Tonality(Note.d, Modes.major),
const Tonality(Note.c, Modes.minor),
const Tonality(Note.dFlat, Modes.major),
const Tonality(Note.d, Modes.major),
const Tonality(Note.eFlat, Modes.major),
const Tonality(Note.fSharp, Modes.minor),
const Tonality(Note.dFlat, Modes.major),
]);
});
});
Expand Down

0 comments on commit 485284c

Please sign in to comment.