Ben 1 年之前
父节点
当前提交
09a754b40a
共有 1 个文件被更改,包括 10 次插入3 次删除
  1. 10 3
      internal/server/server.go

+ 10 - 3
internal/server/server.go

@@ -158,13 +158,20 @@ func Group(c *gin.Context) {
 		dtoNodes = append(dtoNodes, convert2DtoNode(node, countryLabelSeqs[node.CountryCode]))
 	}
 
-	continents := make(map[string]bool)
+	continentMaps := make(map[string]bool)
 	for _, node := range dtoNodes {
-		continents[node.Continent] = true
+		continentMaps[node.Continent] = true
 	}
+	continents := make([]string, 0)
+	for continent := range continentMaps {
+		continents = append(continents, continent)
+	}
+	sort.SliceStable(continents, func(i, j int) bool {
+		return continents[i] > continents[j]
+	})
 
 	groupDtos := make([]*dto.Group, 0)
-	for continent := range continents {
+	for _, continent := range continents {
 		groupDto := &dto.Group{
 			Continent: continent,
 			Nodes:     make([]*dto.Node, 0),