C sort and search algorithms