Reputation: 19
I have a list something like below.
What I am looking for is simple way of formatting this in a table and sorting this list based either upon the 'no of times' or 'duration'
Note: I have tried 'tabulate' package but didn't give me proper results.
Upvotes: 0
Views: 46
Reputation: 22954
The data structure you must use is dictionary, So you can represent the data as :
data = {"com.a0soft.gphone.app2sd": [3, 28945],
"com.whatsapp" : [24, 1800631],
"com.android.vending" : [3, 305155] }
package_name = data.keys()
package_name.sort(key = lambda x:data[x][0]) #sorting this list based upon the 'no of times'
package_name.sort(key = lambda x:data[x][1]) #sorting this list based upon the 'duration'
Output:
['com.a0soft.gphone.app2sd', 'com.android.vending', 'com.whatsapp']
#sorting this list based upon the 'no of times'
['com.a0soft.gphone.app2sd', 'com.android.vending', 'com.whatsapp']
#sorting this list based upon the 'duration'
Upvotes: 1