Tweak sorting algorithm for searching