Jump to content
xisto Community
Klass

Ascend Descend Sorting

Recommended Posts

I am at a loss for trying to use javascript to ascend descend sort my columns.

Here is the code I am trying to sort:

<tr> <td class='row$row' width="25%"><a href="{ipb.script_url}act=army&userstat={$user['id']}">{$user['name']}</td> <td class='row$row' width="15%">{$user['rank']}</td> <td class='row$row' width="10%" align=right>{$user['army']}</td> <td class='row$row' width="10%">{$user['racename']}  <img src='{$user['raceicon']}' border='0' height=28 width=28></td> <td class='row$row' width="15%" align=right>{$user['money']}</td> <!--attack--><td class='row$row' width="30%" align=center><b><a href="{ipb.script_url}act=army&CODE=05&ID={$user['id']}">{ipb.lang['atkuser']}</a></b></td><!--attack--></tr>
The things that need to be sorted are: 'name', 'army', 'money'.
Want to sort 'rank' by default, which is how the code/database is already set. Then when user wants to sort use above in a javascript.

Share this post


Link to post
Share on other sites

Let me get this straight. Currently the system sorts by rank, but you want the user to be able to sort by name, army, and money. First of all, sorting by money (since this is for the army system) would allow users to get a feel for who has what amount even if it is question marks instead of a gold listing because there spy is too low. Then let me refer you to this thread which talks about various sorting algorithms. I would use qwijibow's bubble sort as it is fast and not very complicated. However, quicksort will work as well. Both are well documented and a search should provide all the information you need if (as I suspect you are) you are capable of taking an algorithm and coding it.

~Viz

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.