mirror of
https://github.com/logos-storage/logos-storage-go.git
synced 2026-01-07 15:53:09 +00:00
use go library function for sorting
This commit is contained in:
parent
b1e38bc697
commit
8a16db8f30
@ -154,14 +154,16 @@ func (d *CodexArchiveDownloader) downloadAllArchives() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort by timestamp (newest first) - same as torrent version
|
// Sort by timestamp (newest first)
|
||||||
for i := 0; i < len(archivesList)-1; i++ {
|
slices.SortFunc(archivesList, func(a, b archiveInfo) int {
|
||||||
for j := i + 1; j < len(archivesList); j++ {
|
if a.from > b.from {
|
||||||
if archivesList[i].from < archivesList[j].from {
|
return -1 // a is newer, should come first
|
||||||
archivesList[i], archivesList[j] = archivesList[j], archivesList[i]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if a.from < b.from {
|
||||||
|
return 1 // b is newer, should come first
|
||||||
}
|
}
|
||||||
|
return 0 // equal timestamps
|
||||||
|
})
|
||||||
|
|
||||||
// Monitor for cancellation in a separate goroutine
|
// Monitor for cancellation in a separate goroutine
|
||||||
go func() {
|
go func() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user