blob: 6c97ee3526512d3d175b74b54e9d20180f006870 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
package gallery
import "sort"
// sortPhotos orders photos by date taken (newest first).
//
// Photos with identical timestamps are ordered by relative path to
// provide deterministic output.
func sortPhotos(photos []Photo) {
sort.SliceStable(photos, func(i, j int) bool {
if !photos[i].DateTaken.Equal(photos[j].DateTaken) {
return photos[i].DateTaken.After(photos[j].DateTaken)
}
return photos[i].RelativePath < photos[j].RelativePath
})
}
|