The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7155

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===

From e5e1b45192035345cd5cb1470bb86012b73707e3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Tue, 7 Apr 2020 21:39:57 -0400
Subject: [PATCH 1/2] lxc: Use natural string sorting
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes #7149

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxc/utils.go | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lxc/utils.go b/lxc/utils.go
index a34c1bb26e..b242660f90 100644
--- a/lxc/utils.go
+++ b/lxc/utils.go
@@ -8,6 +8,7 @@ import (
        "strings"
 
        "github.com/pkg/errors"
+       "vbom.ml/util/sortorder"
 
        lxd "github.com/lxc/lxd/client"
        "github.com/lxc/lxd/shared/api"
@@ -41,7 +42,7 @@ func (a stringList) Less(i, j int) bool {
                return true
        }
 
-       return a[i][x] < a[j][x]
+       return sortorder.NaturalLess(a[i][x], a[j][x])
 }
 
 // Instance name sorting
@@ -64,7 +65,7 @@ func (a byName) Less(i, j int) bool {
                return true
        }
 
-       return a[i][0] < a[j][0]
+       return sortorder.NaturalLess(a[i][0], a[j][0])
 }
 
 // Storage volume sorting
@@ -80,7 +81,7 @@ func (a byNameAndType) Swap(i, j int) {
 
 func (a byNameAndType) Less(i, j int) bool {
        if a[i][0] != a[j][0] {
-               return a[i][0] < a[j][0]
+               return sortorder.NaturalLess(a[i][0], a[j][0])
        }
 
        if a[i][1] == "" {
@@ -91,7 +92,7 @@ func (a byNameAndType) Less(i, j int) bool {
                return true
        }
 
-       return a[i][1] < a[j][1]
+       return sortorder.NaturalLess(a[i][1], a[j][1])
 }
 
 // Batch operations

From 13546f9cb337813ed1530324089c1208ede091f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Tue, 7 Apr 2020 21:45:46 -0400
Subject: [PATCH 2/2] lxc: Group snapshot and parent
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxc/utils.go | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lxc/utils.go b/lxc/utils.go
index b242660f90..6dcbb9b285 100644
--- a/lxc/utils.go
+++ b/lxc/utils.go
@@ -80,7 +80,11 @@ func (a byNameAndType) Swap(i, j int) {
 }
 
 func (a byNameAndType) Less(i, j int) bool {
-       if a[i][0] != a[j][0] {
+       // Sort snapshot and parent together.
+       iType := strings.Split(a[i][0], " ")[0]
+       jType := strings.Split(a[j][0], " ")[0]
+
+       if iType != jType {
                return sortorder.NaturalLess(a[i][0], a[j][0])
        }
 
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to