Skip to content

Instantly share code, notes, and snippets.

@9helix
Created April 6, 2022 14:06
Show Gist options
  • Save 9helix/d7f757ef86dfecd03714db38bdac8d8e to your computer and use it in GitHub Desktop.
Save 9helix/d7f757ef86dfecd03714db38bdac8d8e to your computer and use it in GitHub Desktop.
custom sort dart
void main() {
getFreq(n) {
return int.parse(n.substring(n.indexOf(';') + 1, n.length));
}
final List<String> words = <String>['krak;56', 'mrak;1500', 'brak;480'];
words.sort((a, b) => getFreq(a).compareTo(getFreq(b)));
print(words);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment