mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-24 00:54:17 +02:00
Ensure sorting is stable: type -> timestamp -> path/ID
This commit is contained in:
parent
71d6ab0476
commit
6b21789417
1 changed files with 11 additions and 1 deletions
12
ui/stash.go
12
ui/stash.go
|
|
@ -74,7 +74,17 @@ func (m markdownsByLocalFirst) Less(i, j int) bool {
|
|||
}
|
||||
|
||||
// Both or neither are local files so sort by date descending
|
||||
return m[i].CreatedAt.After(*m[j].CreatedAt)
|
||||
if !m[i].CreatedAt.Equal(*m[j].CreatedAt) {
|
||||
return m[i].CreatedAt.After(*m[j].CreatedAt)
|
||||
}
|
||||
|
||||
// If the timestamps also match, sort by ID/path
|
||||
if iType != localMarkdown {
|
||||
// non-local items have an ID
|
||||
return m[i].ID > m[j].ID
|
||||
}
|
||||
|
||||
return strings.Compare(m[i].localPath, m[j].localPath) == -1
|
||||
}
|
||||
|
||||
type loadedState byte
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue