out[ ]array([ ][- - - ] - - ]]lexsort is similar to argsortbut it performs an indirect lexicographical sort on multiple key arrays suppose we wanted to sort some data identified by first and last namesin [ ]first_name np array(['bob''jane''steve''bill''barbara']in [ ]last_name np array(['jones''arnold''arnold''jones''walters']in [ ]sorter np lexsort((first_namelast_name)in [ ]zip(last_name[sorter]first_name[sorter]out[ ][('arnold''jane')('arnold''steve')('jones''bill')('jones''bob')('walters''barbara')lexsort can be bit confusing the first time you use it because the order in which the keys are used to order the data starts with the last array passed as you can seelast_name was used before first_name pandas methods like series' and dataframe' sort_index methods and the series order method are implemented with variants of these functions (which also must take into account missing valuesalternate sort algorithms stable sorting algorithm preserves the relative position of equal elements this can be especially important in indirect sorts where the relative ordering is meaningfulin [ ]values np array([' :first'' :second'' :first'' :second'' :third']in [ ]key np array([ ]in [ ]indexer key argsort(kind='mergesort'in [ ]indexer out[ ]array([ ]in [ ]values take(indexerout[ ]array([' :first'' :second'' :third'' :first'' :second']dtype='| 'the only stable sort available is mergesort which has guaranteed ( log nperformance (for complexity buffs)but its performance is on average worse than the default more about sorting www it-ebooks info