Example #1
0
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
}
Example #2
0
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]
	}
}
Example #3
0
// 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]
}
Example #4
0
// 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)
}