當前位置: 首頁>>代碼示例>>Golang>>正文


Golang naturalsort.NaturalSort函數代碼示例

本文整理匯總了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
}
開發者ID:o1egl,項目名稱:govatar,代碼行數:8,代碼來源:govatar.go

示例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]
	}
}
開發者ID:rdgreis,項目名稱:machine,代碼行數:13,代碼來源:commands.go

示例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]
}
開發者ID:gen2brain,項目名稱:cbconvert,代碼行數:17,代碼來源:cbconvert.go

示例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)
}
開發者ID:rkazak,項目名稱:swarm,代碼行數:5,代碼來源:engine_sorter.go


注:本文中的github.com/skarademir/naturalsort.NaturalSort函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。