-
Notifications
You must be signed in to change notification settings - Fork 27k
Description
Issue / Improvement / Feature Request
Relevant Package
@angular/common (source)
Description
Currently the keyvalue pipe sorts the keys. This result in e.g.
1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 20, 21, ...
Because it's not natual sorted. ...
Describe the solution you'd like
It should not sort by default. Respect the original object state.
It's annoying to declare a no sort method to each component which uses keyvalue. (function that returns 0 for no sort.)
Describe alternatives you've considered
Provide predefined sort functions. The parameter of keyvalue could be a string or function. The string is the name of the predefined buildin function of Angular. Like:
keyvalue: 'natural'
keyvalue: 'sort' // the current sort behavior
keyvalue: mySort // a custom function
keyvalue // default no parameter, no sort.Or we could invert the logic so that no parameter means the current behvaior but keyvalue: 'none' disables the sort. For downwards compatibility. If you care about. But in my opinion we should ignore that. A tiny breaking change. The migration is simple: Just add 'sort' to the keyvalue pipe. So I still prefer my solution: Don't sort by default.