Skip to content

Instantly share code, notes, and snippets.

@betandr
Created March 1, 2019 07:33
Show Gist options
  • Save betandr/becbc6b0db014ab9ef4954bd672333b2 to your computer and use it in GitHub Desktop.
Save betandr/becbc6b0db014ab9ef4954bd672333b2 to your computer and use it in GitHub Desktop.
sort.Interface sort by title, artist
type byTitleArtist []*Track
func (t byTitleArtist) Len() int { return len(t) }
func (t byTitleArtist) Swap(i, j int) { t[i], t[j] = t[j], t[i] }
func (t byTitleArtist) Less(i, j int) bool {
if toL(t[i].Title) < toL(t[j].Title) {
return true
}
if toL(t[i].Title) > toL(t[j].Title) {
return false
}
return toL(t[i].Artist) < toL(t[j].Artist)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment