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

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -