Galaxy Legion Forum http://galaxylegion.com/forum/ |
|
Battle tab sorting http://galaxylegion.com/forum/viewtopic.php?f=5&t=25090 |
Page 1 of 1 |
Author: | Drekentai [ Mon May 21, 2012 6:37 pm ] |
Post subject: | Battle tab sorting |
I'm pretty sure it occasionally happens to a lot to see a ship in battle tab randomly that has no debuffs on what so ever that's far, far stronger. But I found a glitch in the process of going through battle tab, sorting puts the higher rank in reverse order. ![]() Almost seems as if GL sorts by first 3 numbers, instead of just sorting by the whole number; that sounds like a ridiculous method. |
Author: | senatorhung [ Tue May 22, 2012 1:30 am ] |
Post subject: | Re: Battle tab sorting |
yeah, i get my 105s before my 70s in my BT. sorting by alpha vs. sorting by numbers ... |
Author: | QCubed [ Tue May 22, 2012 5:54 am ] |
Post subject: | Re: Battle tab sorting |
Drekentai wrote: I'm pretty sure it occasionally happens to a lot to see a ship in battle tab randomly that has no debuffs on what so ever that's far, far stronger. But I found a glitch in the process of going through battle tab, sorting puts the higher rank in reverse order. ![]() Almost seems as if GL sorts by first 3 numbers, instead of just sorting by the whole number; that sounds like a ridiculous method. What: Actually, this indicates that the ASP is treating the ranks as STRINGS instead of numbers for sorting. for an example use windows file system, it treats all file names as strings even if they are entirely composed of didgits. How: When you compare strings you compare from the 1st didgit forward, and extra didgits are compared verses nulls. Why: String compare uses the ascii (or now a-days unicode if supported) character values to determine if one should be above another. Since special characters come first, followed by numbers followed by letters you get "wierd" sorting Notes: I use this loophope to nail important folders or files to the top of a file list all the time at work, I will stick a bang/exclamation-point at the begining of something I always want to sort to the top. When you use string compares this way you would have to pad the begingins with 0s to make the sort correct. So in a file system I always use a larger number than I expect a set of filews or folders, or servers to reach. I might name my servers: GL-Web01, GL-Web02, GL-Web03 I might name files GL_001.html, GL_002.html, GL_003.html That is pretty much the only way to get strings to compare correctly as they would in a true numerical sort. Solution(s): It IS possible for Dan to change this code to treat those values as true numbers, or he could also change the web-code to count characters and pad 0s at the begining; both of these options might be a bit slower to sort the list though. Another option, which should be snappier, is he could change the view he grabs the sql data from to have two columns, one the normal rank as we see it, one a, say 8 character "rank" that has padded 0s and is a string representation of the rank of the user, it should be a pretty simple thing to implement, then just use that as a hidden column in the interface for him to do sorting on.. |
Author: | Drekentai [ Tue May 22, 2012 6:13 am ] |
Post subject: | Re: Battle tab sorting |
QCubed wrote: What: Actually, this indicates that the ASP is treating the ranks as STRINGS instead of numbers for sorting. for an example use windows file system, it treats all file names as strings even if they are entirely composed of didgits. How: When you compare strings you compare from the 1st didgit forward, and extra didgits are compared verses nulls. Why: String compare uses the ascii (or now a-days unicode if supported) character values to determine if one should be above another. Since special characters come first, followed by numbers followed by letters you get "wierd" sorting Notes: I use this loophope to nail important folders or files to the top of a file list all the time at work, I will stick a bang/exclamation-point at the begining of something I always want to sort to the top. When you use string compares this way you would have to pad the begingins with 0s to make the sort correct. So in a file system I always use a larger number than I expect a set of filews or folders, or servers to reach. I might name my servers: GL-Web01, GL-Web02, GL-Web03 I might name files GL_001.html, GL_002.html, GL_003.html That is pretty much the only way to get strings to compare correctly as they would in a true numerical sort. Solution(s): It IS possible for Dan to change this code to treat those values as true numbers, or he could also change the web-code to count characters and pad 0s at the begining; both of these options might be a bit slower to sort the list though. Another option, which should be snappier, is he could change the view he grabs the sql data from to have two columns, one the normal rank as we see it, one a, say 8 character "rank" that has padded 0s and is a string representation of the rank of the user, it should be a pretty simple thing to implement, then just use that as a hidden column in the interface for him to do sorting on.. Even though this theory is correct and solution would work; GL runs on PHP, not ASP. To my memory from ASP.NET programming; it doesn't have pre-made sorting methods. But PHP does include this, which leads me to wonder if they were used or if Dan made his own sort method. PHP's built in sort methods can sort letters and numbers combined (flags can be included to specify a certain sort pattern). So if you passed say, your sever names as an array in the sort method in mixed order, you can easily have it sort by the end numbers - instead of the first character (php sort - for reference). Though, because the sorting itself is done with javascript, the actual programming language itself is irrelevant. So the issue would lay within the sorting method used within javascript. |
Author: | QCubed [ Wed May 23, 2012 2:51 pm ] |
Post subject: | Re: Battle tab sorting |
sorry, my bad, php, I always default to asp.net since most of the web-apps I support have been asp.net; in both cases you could use use javascript as you mentioned. Javascript also offers the ability to sort via numeric values as well: Sort numbers (numerically and ascending): var points = [40,100,1,5,25,10]; points.sort(function(a,b){return a-b}); The result of points will be: 1,5,10,25,40,100 That said, just FYI, asp.net can sort numbers as numbers so long as their data-type is numberic, and not string, if it's sting then you go through the same hoops I described, if you type them as numbers then the sorting works properly using the sort method. |
Author: | Epicownage [ Wed May 23, 2012 4:30 pm ] |
Post subject: | Re: Battle tab sorting |
Am I the only one who is completely and utterly lost? |
Author: | QCubed [ Wed May 23, 2012 4:41 pm ] |
Post subject: | Re: Battle tab sorting |
Epicownage wrote: Am I the only one who is completely and utterly lost? Yes ![]() |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |