View Single Post
08-25-10, 08:15 AM   #20
Saiket
A Chromatic Dragonspawn
 
Saiket's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 154
Originally Posted by sacrife View Post
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
This should flip the item quality sort (just replace '<' with '>' to invert) and fall back on item stack counts if two buttons contain the same itemID.
lua Code:
  1. local QuickSort;
  2. do
  3.     local func = function(v1, v2)
  4.         if v1[2] ~= v2[2] then
  5.             return v1[2] > v2[2]; -- Higher quality first
  6.         elseif v1[1] ~= v2[1] then
  7.             return v1[1] < v2[1];
  8.         else -- Compare stack counts
  9.             local _, c1 = GetContainerItemInfo(v1[3].bagID, v1[3].slotID);
  10.             local _, c2 = GetContainerItemInfo(v2[3].bagID, v2[3].slotID);
  11.             return c1 < c2;
  12.         end
  13.     end;
  14.     QuickSort = function(tbl) table.sort(tbl, func); end
  15. end
  Reply With Quote