Sorted set in javascript using binary search