Python 多级排序
来源:互联网 发布:成都软件学院 编辑:程序博客网 时间:2024/05/01 08:15
class C( object ): def __init__( self, x1, x2, x3 ): self.x1 = x1 self.x2 = x2 self.x3 = x3 def __cmp__( self, other ): if self.x1 < other.x1: return -1 elif self.x1 == other.x1: if self.x2 < other.x2: return -1 elif self.x2 == other.x2: if self.x3 < other.x3: return -1 elif self.x3 == other.x3: return 0 else: return 1 else: return 1 else: return 1 def __repr__( self ): return "({x1}, {x2}, {x3})".format( x1 = self.x1, x2 = self.x2, x3 = self.x3 ) import randomr = random.randintli = []for i in xrange( 15 ): li.append( C( r( 1, 10 ), r( 1, 10 ), r( 1, 10 ) ) )for i in li: print iprint li1 = sorted( li )for i in li1: print i
0 0
- Python 多级排序
- 多级排序!
- Python 的列表排序(用 operator 函数进行多级排序)
- Python多级排序(多属性排序)csv文件
- Python中使用operator模块实现对象的多级排序
- Python中使用operator模块实现对象的多级排序
- Python中用sort和class实现多级排序
- criteria多级排序
- 优先队列多级排序
- Java多级排序
- OJ.字符串多级排序
- 结构体排序,多级排序
- python 创建多级目录
- python 创建多级目录
- 对结构体多级排序
- 【多级排序】水王争霸
- pandas多级分组如何排序
- mongoDB更新 python多级操作
- HDU 4764-Stone(博弈)
- 非预期的例外
- SUSE下安装openssl
- 异常说明符
- chrome插件 postman插件 接口测试、API & HTTP 请求调试工具
- Python 多级排序
- 储存webview 的 cookie
- jQuery中的Each
- void类型及void指针
- Cocos2d-x3.2总结(五)Eclipse下生成Android APK提示"DescriptionResourcePathLocationType"的解决方法集锦
- 设计模式6——Factory设计模式
- Android Handler
- 通信协议的定义
- 怎么上谷歌E9加速器器分享移动设备上谷歌的办法