Python Solution of Sorting and Searching part