DEV Community

Discussion on: Binary Search In Javascript

Collapse
 
polmonroig profile image
Pol Monroig Company • Edited

If it is unordered the best way to go is linear search, in case you need to search an LOT of times then and only then I would consider sorting it. Since sorting with comparison methods has at least O(nlogn). Altought i'm ignoring counting methods that can be done linearly

Collapse
 
ogzhanolguncu profile image
Oğuzhan Olguncu

I said I would sort it regarding his question. Since, he asked "how would you sort list first", but you are right going with linear search makes sense if it's unordered.