it' important to know how to use effectively the sort functionality provided by your language' library let' say we are given student class that implements compare method that compares students by name then by defaultthe array sort library routine will sort by name to sort an array of students by gpawe have to explicitly speicify the compare function to the sort routine class student object )def __init__ (self name grade_point_average )self name name self grade_point_average grade_point_average def __lt__ (self other )return self name other name students student (' ' student (' ' student (' ' student (' ' sort according to __lt__ defined in student students remained unchanged students_sort_by_name sorted students sort students in place by grade_point_average students sort(keylambda student student grade_point_average the time complexity of any reasonable library sort is ( log nfor an array with entries most library sorting functions are based on quicksortwhich has ( space complexity sorting problems come in two flavors( use sorting to make subsequent steps in an algorithm simplerand ( design custom sorting routine for the formerit' fine to use library sort functionpossibly with custom comparator for the latteruse data structure like bstheapor array indexed by values certain problems become easier to understandas well as solvewhen the input is sorted the most natural reason to sort is if the inputs have natural orderingand sorting can be used as preprocessing step to speed up searching for specialized inpute very small range of valuesor small number of valuesit' possible to sort in (ntime rather than ( log ntime it' often the case that sorting can be implemented in less space than required by brute-force approach sometimes it is not obvious what to sort one should collection of intervals be sorted on starting points or endpoints(problem on page table top tips for sorting know your sorting libraries to sort list in-placeuse the sort(methodto sort an iterableuse the function sorted(the sort(method implements stable in-place sort for list objects it returns none-the calling list itself is updated it takes two argumentsboth optionalkey=noneand