Thread: ZO_Helpers
View Single Post
10/11/14, 04:36 PM   #3
Argusus
AddOn Author - Click to view addons
Join Date: Sep 2014
Posts: 120
Originally Posted by merlight View Post
I remember when I wanted to use it I read the code and concluded it was broken. So I wrote my own. Well, it might be me having a bad day and reading the code wrong.

But even if it actually worked, it's badly designed. Unlike table.sort, which expects a comparator that takes 2 arguments and returns a boolean (basically operator '<'; you need to have a sorted table in order to use binary search), zo_binarysearch expects a comparator that takes 3 arguments and returns numeric difference (similar to perl's operator '<=>'; the third argument is index, which is totally irrelevant, but they still use it in their default broken comparator instead of the right-hand value). So in the end, you'd need to write two comparators - one for sorting and another for searching - awful design.
Ah, doesn't surprise me... too much mystery in the addon world right now. The post really relates to me wanting to sort the "masterList" alphabetically by a column when the BuildMasterList is called. it doesn't seem to be doing this by default so maybe i'm missing something there. I was thinking I could sort the table THEN add the items to the masterList object so it sorted by my first column (UnitName) by default.
  Reply With Quote