Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

map is not sorted #20

Open
jiftle opened this issue Sep 10, 2021 · 1 comment
Open

map is not sorted #20

jiftle opened this issue Sep 10, 2021 · 1 comment

Comments

@jiftle
Copy link

jiftle commented Sep 10, 2021

var rs map[string][]byte

// 排序
m := orderedmap.NewOrderedMap()
for k, _ := range rs {
	fmt.Printf("  |-set-> %v\n", el.Key)
	m.Set(k, rs[k])
}

// You can also use Back and Prev to iterate in reverse:
for el := m.Back(); el != nil; el = el.Prev() {
	fmt.Printf("  |-get-> %v\n", el.Key)
}
----> 检索记录,前缀: auth_file_rec-001203-0100000084-
out--find more--> [auth_file_rec-001203-0100000084-%!s(int=23)]:
out--find more--> [auth_file_rec-001203-0100000084-%!s(int=24)]:
out--find more--> [auth_file_rec-001203-0100000084-%!s(int=25)]:
out--find more--> [auth_file_rec-001203-0100000084-%!s(int=26)]:
  |---> auth_file_rec-001203-0100000084-%!s(int=26)
  |---> auth_file_rec-001203-0100000084-%!s(int=25)
  |---> auth_file_rec-001203-0100000084-%!s(int=24)
  |---> auth_file_rec-001203-0100000084-%!s(int=23)
  
  
----> 检索记录,前缀: auth_file_rec-001203-0100000084-
out--find more--> [auth_file_rec-001203-0100000084-%!s(int=23)]:
out--find more--> [auth_file_rec-001203-0100000084-%!s(int=24)]:
out--find more--> [auth_file_rec-001203-0100000084-%!s(int=25)]:
out--find more--> [auth_file_rec-001203-0100000084-%!s(int=26)]:
  |---> auth_file_rec-001203-0100000084-%!s(int=24)
  |---> auth_file_rec-001203-0100000084-%!s(int=23)
  |---> auth_file_rec-001203-0100000084-%!s(int=26)
  |---> auth_file_rec-001203-0100000084-%!s(int=25)
@elliotchance
Copy link
Owner

I cannot understand your output because it doesn't match the code you provided.

This package does not provide a sorted map (where items are placed in sorted order), it is an ordered map (where insert order is maintained).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants