转载于:http://blog.csdn.net/u012005313/article/details/49154683
参考:
http://www.cnblogs.com/100thMountain/p/4719503.html
http://blog.163.com/zhuandi_h/blog/static/1802702882012111284632184/
《Machine Learning In Action》第二章
###############################################################
operator.itemgetter函数:
operator模块提供的itemgetter函数用于获取对象的哪些维的数据,参数为一些序号(即需要获取的数据在对象中的序号)
note that:operator.itemgetter函数获取的不是值,而是定义了一个函数,通过该函数作用到对象上才能获取值。
##################################################################
sorted函数
sorted函数是内建函数
参数解释:
iterable:指定为要排序的list或iterable对象
cmp:接受一个函数(有两个参数),指定排序时进行比较的函数,可以指定一个函数或lambda表达式,如:
key:接受一个函数(只有一个参数),指定待排序元素的哪一项进行排序:
reverse:是一个bool变量,表示升序还是降序排列,默认为false(升序排列),定义为True时表示降序排列
#####################################################################################
sorted函数和operator.itemgetter函数的使用
通过stu的第三个域进行排序
进行多级排序,即先跟第三个域进行排序,再根据第二个域排序(反过来了)