Skip to content

Commit 26858c3

Browse files
Merge pull request #375 from jesseduffield/sort-volumes-by-labels
2 parents 0e0997d + ec8dfba commit 26858c3

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/commands/volume.go

+9
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,16 @@ func (c *DockerCommand) RefreshVolumes() error {
3636

3737
ownVolumes := make([]*Volume, len(volumes))
3838

39+
// we're sorting these volumes based on whether they have labels defined,
40+
// because those are the ones you typically care about.
41+
// Within that, we also sort them alphabetically
3942
sort.Slice(volumes, func(i, j int) bool {
43+
if len(volumes[i].Labels) == 0 && len(volumes[j].Labels) > 0 {
44+
return false
45+
}
46+
if len(volumes[i].Labels) > 0 && len(volumes[j].Labels) == 0 {
47+
return true
48+
}
4049
return volumes[i].Name < volumes[j].Name
4150
})
4251

0 commit comments

Comments
 (0)