Skip to content

Add sort for ListView#107

Merged
texus merged 3 commits intotexus:0.8from
Kvaz1r:SortListView
Sep 7, 2019
Merged

Add sort for ListView#107
texus merged 3 commits intotexus:0.8from
Kvaz1r:SortListView

Conversation

@Kvaz1r
Copy link
Contributor

@Kvaz1r Kvaz1r commented Sep 7, 2019

I not think that it's the best solution but as for me it's still better than removing all items and adding them back on each sorting.

If these changes is appropriate I'll also add tests.

@texus
Copy link
Owner

texus commented Sep 7, 2019

This definitely looks like a useful function.

Could you perhaps swap the parameters of the sort function (so first the index and then the comparator)? I think that it might be slightly more readably when calling the function with a lambda function as comparator.

I don't really like that both variables are initialized on one line, so maybe you could also either use a ternary operator (and make s1 and s2 const) or rewrite the function as follows?

sf::String s1;
if (index < a.texts.size())
    s1 = a.texts[index].getString();

sf::String s2;
if (index < b.texts.size())
    s2 = b.texts[index].getString();

@Kvaz1r
Copy link
Contributor Author

Kvaz1r commented Sep 7, 2019

good points, I'll fix it.

@texus texus merged commit 95b7002 into texus:0.8 Sep 7, 2019
@Kvaz1r Kvaz1r deleted the SortListView branch September 7, 2019 20:41
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

Successfully merging this pull request may close these issues.

2 participants