Sort « Format « Python Data Type Q&A

Home
Python Data Type Q&A
1.array
2.date
3.dictionary
4.Format
5.integer
6.List
7.numpy
8.regex
9.string
10.tuple
Python Data Type Q&A » Format » Sort 

1. Sorting numbers in string format with Python    stackoverflow.com

I have a list that has some chapter numbers in string. When I sort the keys using keys function, it gives me wrong results.

keys = ['1.1', '1.2', '2.1', '10.1'] 
keys.sort() 
print keys

['1.1', ...

2. String Sort based on some Format    stackoverflow.com

I have a string which needs to be sorted based on the sort_fmt. Ex: If the string is 'abdcdfs' & the sort_fmt is 'dacg'. Upon sort, the output should be 'ddacfbs'. ...

3. Need to take average of long, strangely formatted set of data in Python    stackoverflow.com

So I have a large set of data that looks like this

[('ART', [100, 234, 830, 304]), ('MATH', [600, 1400, 300, 340]), ('HISTORY', [2010, 300,   400, 600])]
How would I ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.