1 result =[['7250','1'],['7510','2'],['7759','0'],['6523','33']]
 2 
 3 copy_result = []
 4 
 5 for item in result:
 6     copy_result.append([int(item[0]),item[1]])
 7 
 8 print result
 9 # output:
10 # [['7250', '1'], ['7510', '2'], ['7759', '0'], ['6523', '33']]
11 
12 print copy_result
13 # output
14 # [[7250, '1'], [7510, '2'], [7759, '0'], [6523, '33']]
15 
16 copy_result.sort()
17 
18 print copy_result
19 # output
20 # [[6523, '33'], [7250, '1'], [7510, '2'], [7759, '0']]
21 
22 back_result = []
23 
24 for item in copy_result:
25     back_result.append([str(item[0]),item[1]])
26 
27 print back_result
28 # output
29 # [['6523', '33'], ['7250', '1'], ['7510', '2'], ['7759', '0']]
 
用int()和str()转换数据类型

二维数组的排序 sort()方法根据第一维的排序 
 

如果是逆序,用reverse()

 

posted on 2014-08-07 16:56  cpycpp  阅读(263)  评论(0编辑  收藏  举报