News:

A forum for users of LackeyCCG

Main Menu

Sort card number numerically

Started by deadgames, July 31, 2012, 01:24:13 PM

Previous topic - Next topic

deadgames

I'm working on a plugin, and I included the card number as one of the columns. That column gets sorted in "1, 10, 100, 11, 12" order, rather than "1, 2, 3". It's sorted lexicographically, rather than numerically. Can that be changed? I could pad the numbers with leading zeros, but I'd like to be able to skip that if possible.

Trevor

#1
It's a bit more complicated than it seems. When a column is made, there is no way for the program to tell if the data should be sorted numerically or alphabetically without something explicitly telling it so, and that would be one extra step the plugin creator would need to do for every column, and this would require a lot more complexity than is currently needed. Currently, a plugin maker doesn't need to do anything to specify things like how many columns of data it expects, or how many card entries it should expect, or anything like that. So to add some information about the columns would require that information to be added elsewhere, and then the plugin maker would also be responsible for making the card data file consistent with the defined ordering method and column relationship.
But even when a column is supposed to be evaluated as numerically, it is often the case that there are other letters or symbols in some of the cards, which then again raises the issue of how things should be sorted.

It's not perfect, but right now I suggest to either use trailing zeros, or just deal with the fact that things aren't ordered perfectly. In the latter case, it doesn't really matter with most searches. If you sort a bunch of character cards by strength value, you should be able to make sense of what's going on with the search results.

If enough people were sufficiently bothered, I'd try to improve things, but I don't really think it's a big problem.

deadgames

I figured that'd be the case, but I wanted to make sure. I'll just pad with leading zeros.