map is not sorted

Open
#20 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
go
Domain
tooling

Research direction

The report provides no repository file or test name; begin by reproducing the example using orderedmap.NewOrderedMap, Set, Back, and Prev. Compare the observed order with the intended ordering and determine whether the issue is in orderedmap or in the unordered source map iteration. Done means the expected ordering is explicitly established and verified by a focused regression test.

Written by the indexing model from the issue text.

Description

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)
Dominant language
Go
Stars
1k
Forks
77
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from elliotchance/orderedmap

All issues in elliotchance/orderedmap

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.