本文整理匯總了Golang中github.com/skarademir/naturalsort.NaturalSort函數的典型用法代碼示例。如果您正苦於以下問題:Golang NaturalSort函數的具體用法?Golang NaturalSort怎麽用?Golang NaturalSort使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NaturalSort函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: readAssetsFrom
func readAssetsFrom(dir string) []string {
assets, _ := AssetDir(dir)
for i, asset := range assets {
assets[i] = filepath.Join(dir, asset)
}
sort.Sort(naturalsort.NaturalSort(assets))
return assets
}
示例2: sortHostListItemsByName
func sortHostListItemsByName(items []libmachine.HostListItem) {
m := make(map[string]libmachine.HostListItem, len(items))
s := make([]string, len(items))
for i, v := range items {
name := strings.ToLower(v.Name)
m[name] = v
s[i] = name
}
sort.Sort(naturalsort.NaturalSort(s))
for i, v := range s {
items[i] = m[v]
}
}
示例3: getCover
// Returns the filename that is the most likely to be the cover
func (c *Convertor) getCover(images []string) string {
if len(images) == 0 {
return ""
}
for _, i := range images {
e := c.getBasename(i)
if strings.HasPrefix(i, "cover") || strings.HasPrefix(i, "front") ||
strings.HasSuffix(e, "cover") || strings.HasSuffix(e, "front") {
return i
}
}
sort.Sort(naturalsort.NaturalSort(images))
return images[0]
}
示例4: Less
// Less reports whether the engine with index i should sort before the engine with index j.
// Engines are sorted chronologically by name.
func (s EngineSorter) Less(i, j int) bool {
return naturalsort.NaturalSort([]string{s[i].Name, s[j].Name}).Less(0, 1)
}