Closed yanofsky closed 12 years ago
Agreed, however is you reverse and then later re-run sort what do you get? It also becomes a configuration parameter on your comparator. Will have a think.
@yanofsky could you provide us with a use case for this scenario? I am struggling to understand when you might need this functionality.
Two cases I have in mind.
To address the @alexgraul question from before perhaps a the reverse method takes an optional boolean that indicates whether the reverse is sticky or not, and the dataview gets a boolean property such as "isReversed" indicating if the view is reversed or not. Calling dataview.reverse(true) would reverse the dataset on subsequent sort() calls. dataview.reverse(false) or .reverse() would only keep the dataview reversed only until the next sort() call.
Are you asking for effectively a reversed .each in the first case? Sounds like you'd like to iterate over sorted data backwards. That might make a very sensible addition. For use case 2, can you provide reduced jsFiddle?
A reversed .each would work in both cases. Here's a trivial example of case 2 http://jsfiddle.net/2b6Jw/
Excellent, I think we have a solution!
There currently doesn't appear to be a way to reverse the sort of a Dataview without resorting. This would be a good method to have.