Python solution of Sorting and Searching part