Python Linked Lists- Sorting between linked lists -


suppose have array, in elements linked lists themselves, ordering based on highest element present in list. elements in linked lists can integers, floats or strings. so, linked list has highest valued elements sits @ 0th position in array after sorting. how go sorting between n such linked lists?

you can use sorted lambda function search max of each linked list. example

>>> l = [[1,7,3], [2,4,5], [0,9,3]] >>> sorted(l, key=lambda i: max(i), reverse=true) [[0, 9, 3], [1, 7, 3], [2, 4, 5]] 

this work same way if had array of linked lists long call max on linked list.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -