Created
March 1, 2019 07:33
-
-
Save betandr/becbc6b0db014ab9ef4954bd672333b2 to your computer and use it in GitHub Desktop.
sort.Interface sort by title, artist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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