CoCalc Shared Filesgrants / bio_stein / scratch.sagewsOpen in CoCalc with one click!
Author: William A. Stein
Views : 12
a = """Jennifer S. Balakrishnan, J. Steffen M\\"uller, Mirela Ciperiani, John Coates, Tim Dokchitser, Zhibin Liang, Ramdorai Sujatha, Barry Mazur, Jonathan Bober, Alyson Deines, Ariah Klages-Mundt, Benjamin LeVeque, R. Andrew Ohana, A. Rabindranath, Paul Sharaba, Henri Darmon, Victor Rotger, Michael Daub, Sam Lichtenstein, Christian Wuthrich, Robert Bradshaw, Burcin Erocal, Clement Pernet."""
v = [' '.join(x.strip().split()) for x in a.split(',')] v
['Jennifer S. Balakrishnan', 'J. Steffen M\\"uller', 'Mirela Ciperiani', 'John Coates', 'Tim Dokchitser', 'Zhibin Liang', 'Ramdorai Sujatha', 'Barry Mazur', 'Jonathan Bober', 'Alyson Deines', 'Ariah Klages-Mundt', 'Benjamin LeVeque', 'R. Andrew Ohana', 'A. Rabindranath', 'Paul Sharaba', 'Henri Darmon', 'Victor Rotger', 'Michael Daub', 'Sam Lichtenstein', 'Christian Wuthrich', 'Robert Bradshaw', 'Burcin Erocal', 'Clement Pernet.']
def f(a,b): return cmp(a.split()[-1],b.split()[-1]) v.sort(f)
v
['Jennifer S. Balakrishnan', 'Jonathan Bober', 'Robert Bradshaw', 'Mirela Ciperiani', 'John Coates', 'Henri Darmon', 'Michael Daub', 'Alyson Deines', 'Tim Dokchitser', 'Burcin Erocal', 'Ariah Klages-Mundt', 'Benjamin LeVeque', 'Zhibin Liang', 'Sam Lichtenstein', 'J. Steffen M\\"uller', 'Barry Mazur', 'R. Andrew Ohana', 'Clement Pernet.', 'A. Rabindranath', 'Victor Rotger', 'Paul Sharaba', 'Ramdorai Sujatha', 'Christian Wuthrich']
', '.join(v)
'Jennifer S. Balakrishnan, Jonathan Bober, Robert Bradshaw, Mirela Ciperiani, John Coates, Henri Darmon, Michael Daub, Alyson Deines, Tim Dokchitser, Burcin Erocal, Ariah Klages-Mundt, Benjamin LeVeque, Zhibin Liang, Sam Lichtenstein, J. Steffen M"uller, Barry Mazur, R. Andrew Ohana, Clement Pernet., A. Rabindranath, Victor Rotger, Paul Sharaba, Ramdorai Sujatha, Christian Wuthrich'
len(v)
23
64+32
96