On 1/18/2017, Peter Otten wrote: > with partite.txt looking like this > > > 74' Kessie' > > 90' + 4' D'alessandro > > 51' Mchedlidze > > 54' Banega > > 56' Icardi > > 65' Icardi > > 14' Sau > > > Assuming you want to perform a numerical sort on the numbers before the ' > you can just apply sorted > > with open(...) as f: > print("".join(sorted(f)) > > as long as all number strings have the same length. > > If that's not the case python's sorted() has decorate-sort-undecorate > capabilities built in -- no need to do it manually: > > with open("partite.txt") as f: > by_number = sorted(f, key=lambda line: int(line.partition("'")[0])) > print("".join(by_number))
puts IO.readlines('foo.txt').sort_by( &:to_i ) 14' Sau 51' Mchedlidze 54' Banega 56' Icardi 65' Icardi 74' Kessie' 90' + 4' D'alessandro ==>nil -- Jews totally run Hollywood.... But I don't care if Americans think we're running the news media, Hollywood, Wall Street, or the government. I just care that we get to keep running them. --- Joel Stein articles.latimes.com/2008/dec/19/opinion/oe-stein19 archive.org/download/DavidDukeTv/DoJewsControlTheMediaTheLaTimesSaysYes.flv -- https://mail.python.org/mailman/listinfo/python-list