24 lines
475 B
Go
24 lines
475 B
Go
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
package detectors
|
|
|
|
import (
|
|
"sort"
|
|
"strconv"
|
|
)
|
|
|
|
func sortedFDs(targets map[string]string) []string {
|
|
fds := make([]string, 0, len(targets))
|
|
for fd := range targets {
|
|
fds = append(fds, fd)
|
|
}
|
|
sort.Slice(fds, func(i, j int) bool {
|
|
left, leftErr := strconv.Atoi(fds[i])
|
|
right, rightErr := strconv.Atoi(fds[j])
|
|
if leftErr == nil && rightErr == nil {
|
|
return left < right
|
|
}
|
|
return fds[i] < fds[j]
|
|
})
|
|
return fds
|
|
}
|