3 Jun 2006 17:46:49 -0700, greenflame <[EMAIL PROTECTED]>: > Suppose the main list is: mainlist = list('qwertyuiop') > > Suppose the ordering list is: orderinglist = [3, 4, 2, 1] > > Then I am looking for a function that will take mainlist and > orderinglist as arguments and return the following list: > > ['e', 'r', 'w', 'q', 't', 'y', 'u', 'i', 'o', 'p']
>>> mainlist = list('qwertyuiop') >>> orderinglist = [3, 4, 2, 1] >>> [mainlist[i - 1] for i in orderinglist] + mainlist[len(orderinglist):] ['e', 'r', 'w', 'q', 't', 'y', 'u', 'i', 'o', 'p'] Best regards. -- Roberto Bonvallet -- http://mail.python.org/mailman/listinfo/python-list