golang map prints out of order

后端 未结 2 394
轻奢々
轻奢々 2020-12-17 20:07

Why is the map printing out of order, and how do I get it in to order?

package main

import (
    \"fmt\"
)

type monthsType struct {
    no   int
    text s         


        
2条回答
  •  时光取名叫无心
    2020-12-17 20:33

    Maps are not sorted so you may use a slice to sort your map. Mark Summerfield's book "Programming in Go" explains this on page 204 and is highly recommended.

提交回复
热议问题