mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-21 23:01:03 +00:00
sort volumes first on whether they have labels and secondly on name
This commit is contained in:
parent
0e0997d41a
commit
ec8dfbac06
1 changed files with 9 additions and 0 deletions
|
|
@ -36,7 +36,16 @@ func (c *DockerCommand) RefreshVolumes() error {
|
|||
|
||||
ownVolumes := make([]*Volume, len(volumes))
|
||||
|
||||
// we're sorting these volumes based on whether they have labels defined,
|
||||
// because those are the ones you typically care about.
|
||||
// Within that, we also sort them alphabetically
|
||||
sort.Slice(volumes, func(i, j int) bool {
|
||||
if len(volumes[i].Labels) == 0 && len(volumes[j].Labels) > 0 {
|
||||
return false
|
||||
}
|
||||
if len(volumes[i].Labels) > 0 && len(volumes[j].Labels) == 0 {
|
||||
return true
|
||||
}
|
||||
return volumes[i].Name < volumes[j].Name
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue