Thread: ZO_Helpers
View Single Post
10/11/14, 04:24 PM   #2
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
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.

Last edited by merlight : 10/11/14 at 04:30 PM.
  Reply With Quote