本文整理匯總了Python中streams.Stream.sorted方法的典型用法代碼示例。如果您正苦於以下問題:Python Stream.sorted方法的具體用法?Python Stream.sorted怎麽用?Python Stream.sorted使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類streams.Stream
的用法示例。
在下文中一共展示了Stream.sorted方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_it_should_reverse_sort_the_stream_by_key
# 需要導入模塊: from streams import Stream [as 別名]
# 或者: from streams.Stream import sorted [as 別名]
def test_it_should_reverse_sort_the_stream_by_key(self):
stream = Stream(zip(reversed(range(10)), range(10)))
sorted = stream.sorted(itemgetter(1), reverse=True)
self.assertListEqual(
list(sorted),
list(reversed(list(zip(reversed(range(10)), range(10))))))
示例2: test_it_should_sort_the_stream
# 需要導入模塊: from streams import Stream [as 別名]
# 或者: from streams.Stream import sorted [as 別名]
def test_it_should_sort_the_stream(self):
stream = Stream(reversed(range(10)))
sorted = stream.sorted()
self.assertListEqual(list(sorted), list(xrange(10)))
示例3: test_it_should_sort_the_stream_by_key
# 需要導入模塊: from streams import Stream [as 別名]
# 或者: from streams.Stream import sorted [as 別名]
def test_it_should_sort_the_stream_by_key(self):
zipped = zip(reversed(list(xrange(10))), range(10))
stream = Stream(reversed(list(zipped)))
sorted = stream.sorted(key=itemgetter(1))
self.assertListEqual(list(sorted),
list(zip(reversed(range(10)), range(10))))
示例4: test_sorted
# 需要導入模塊: from streams import Stream [as 別名]
# 或者: from streams.Stream import sorted [as 別名]
def test_sorted(self):
elements = reversed(xrange(100))
stream = Stream(elements)
stream = stream.sorted()
self.assertListEqual(list(stream), list(xrange(100)))