View Single Post
08-25-10, 05:34 AM   #19
sacrife
An Onyxian Warder
 
sacrife's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 384
Originally Posted by Luzzifus View Post
A working version would be this:
lua Code:
  1. local QuickSort;
  2. do
  3.     local func = function(v1, v2)
  4.         if not v1 or not v2 then return (v1 and true or false); end
  5.         if v1[2] ~= v2[2] then
  6.             return v1[2] < v2[2];
  7.         else
  8.             return v1[1] < v2[1];
  9.         end
  10.     end;
  11.     QuickSort = function(tbl) table.sort(tbl, func); end
  12. end

I wrote that recursive sorting function because I didn't find a way to use table.sort with my data structure. I was also aware of the stack overflow errors it produced but I didn't find a way around it. So I hope it's ok if I use your code as a replacement in cargbags_Nivaya too?
I can't see the difference between this code and the one above from SDPhantom. What did you change?

*EDIT*
I added the code from nivaya so it works fine now. Thanks a lot to all parties involved
However, is it possible to add a third sorting? Now it's quality, itemid. Is it possible to add itemcount as a third sort?

And also, how would I go about reversing the quality sort? Now its green > blue > epic. I want to see how it looks the other way.
Its not very important though so don't stress yourself if it's hard ;P
__________________


Last edited by sacrife : 08-25-10 at 05:49 AM.
  Reply With Quote