Stalruth / porysearch

A website that displays a given Pokemon's stats, moves, abilities, and more!
http://stalruth.github.io/porysearch/
GNU General Public License v2.0
1 stars 0 forks source link

Pokemon in "Caught" are not in order. #6

Closed t-mathis closed 9 years ago

t-mathis commented 9 years ago

Pokemon added from the Pokemon tab into "Caught" are not in order. Not sure if bug... or a feature.

Here are the steps I took to do this: 1) Refresh the page. 2) Add Charizard, Charmeleon, then Charmander. 3) Validate that the "Caught" tab added the 3 Pokemon. (It showed 6, then 5, then 4.) 4) Refresh the page, and check again. (It showed 6, then 5, then 4.)

porysearch_bug_2

Stalruth commented 9 years ago

Thanks for reporting! I'll work on this tomorrow. I'll probably use an insertion sort to put them in the right order. (this will mess up the function with people who were using it before, but IMO its worth sorting these things.)

t-mathis commented 9 years ago

That's a good sorting algorithm to use since it will almost always be nearly-sorted anyways, making it super fast.

Stalruth commented 9 years ago

This'll be solved defining a comparator attribute for the CaughtPokemons collection. This feature of backbone uses an insertion sort to ensure the list is always nearly-sorted, and saves me the trouble of writing/maintaining one of my own.

I have it working on my local machine, but only on refresh. I'm currently working to get the table to update as pokemon are added.