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

Feature request: Sorting #51

Closed
rubengees opened this issue Feb 22, 2016 · 11 comments
Closed

Feature request: Sorting #51

rubengees opened this issue Feb 22, 2016 · 11 comments
Assignees
Labels

Comments

@rubengees
Copy link
Contributor

So I just started to try this lib. One thing I am missing is sorting of items.
Sure we could sort our datasets ourself every time but it would be very handy to have something like withComperator(Comparator comparator) or withEnableNaturalSorting(boolean enable).
This could also allow to later just throw a new comparator in and have the data resorted.
I think this would be a very nice feature as most modern apps feature something like "Sort entries by label" and "Sort entries by modification time" like my App does.

@mikepenz mikepenz self-assigned this Feb 22, 2016
@mikepenz
Copy link
Owner

@rubengees I think this is out of scope. You can provide a new list to the FastAdapter at any time. And sorting is as easy as

Collections.sort()

http://docs.oracle.com/javase/6/docs/api/java/util/Collections.html#sort(java.util.List)

No need to add more methods here, as it would just call this single method. I prefer this library to stay really focused.

@rubengees
Copy link
Contributor Author

Yeah sure I know that I can sort myself, but it would be really handy if I won't have to. When I read the description of FastAdapter I thought it was some kind of All-in-one adapter which does all the common things you do with lists without the need for you to write the boilerplate yourself. So I don't think this is out of scope. The lists of other languages like C# offer such functionality out of the box.
And even if it easy, I think it just belongs to the adapter to do such tasks and not into the activity or wherever the adapter is used.

@Rainer-Lang
Copy link
Contributor

@mikepenz In your way I have to get all items from adapter, sort them and then put them back in the adapter? Is this correct?

@mikepenz
Copy link
Owner

@Rainer-Lang normally you know about your items. You have to add them at some point. So I assume that you still know about the items at the point of time when you want to sort them

@Rainer-Lang
Copy link
Contributor

@mikepenz And for "only" re-sorting, which method would you suggest?

  1. set()
  2. setNewList()

mikepenz added a commit that referenced this issue Feb 23, 2016
…s will automatically sort the list as soon as new items are added or set

 * FIX #51
@Rainer-Lang
Copy link
Contributor

@rubengees Please take a look at the newest version.

@rubengees
Copy link
Contributor Author

Great! Thank you.

@Rainer-Lang
Copy link
Contributor

@rubengees Would you like to provide this project with a little sample to this feature?

@Rainer-Lang
Copy link
Contributor

@rubengees
Copy link
Contributor Author

Nice, thank you for adding me 👌

@Rainer-Lang
Copy link
Contributor

Thanks for contributing.

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

No branches or pull requests

3 participants