# HG changeset patch # User Nicolas Saunier # Date 1342039669 14400 # Node ID ee1caff48b039e048b6bb1794b91cf8f54794c5b # Parent 93c26e45efd829ec4ca3dceb2d7a7e74fc23d9b6 added function to sort to list of paired data X,Y diff -r 93c26e45efd8 -r ee1caff48b03 python/utils.py --- a/python/utils.py Wed Jul 11 16:30:23 2012 -0400 +++ b/python/utils.py Wed Jul 11 16:47:49 2012 -0400 @@ -164,6 +164,14 @@ # maths section ######################### +def sortXY(X,Y): + 'returns the sorted (x, Y(x)) sorted on X' + D = {} + for x, y in zip(X,Y): + D[x]=y + xsorted = sorted(D.keys()) + return xsorted, [D[x] for x in xsorted] + def ceilDecimals(v, nDecimals): '''Rounds the number at the nth decimal eg 1.23 at 0 decimal is 2, at 1 decimal is 1.3'''