本文整理汇总了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)
}