On Tue, Apr 14, 2009 at 8:10 PM, wesley chun <[email protected]> wrote:
> > How can I sort the following list in a way that takes care of the right > > order of numbers? The sorted function compares strings here as far as I > can > > see, but I want to have filepath2 follow filepath1. Your help is > > appreciated. > >>>> myList > > ['filepath54', 'filepath25', 'filepath49', 'filepath0', 'filepath89', > > 'filepath52', 'filepath37', 'filepath32', 'filepath2', 'filepath15', > > : > > 'filepath91', 'filepath85', 'filepath9', 'filepath59', 'filepath10', > > 'filepath30', 'filepath31', 'filepath80', 'filepath42', 'filepath74', > > 'filepath21'] > > > unfortunately, we're restricted from solving your homework problems > for you, however, we can tell you that you can still use sorted(). > just combine that with operator.itemgetter(), and you should be well > on your way to solving your problem! > > hope this helps! > -- wesley > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > "Core Python Programming", Prentice Hall, (c)2007,2001 > "Python Fundamentals", Prentice Hall, (c)2009 > http://corepython.com > > wesley.j.chun :: wescpy-at-gmail.com > python training and technical consulting > cyberweb.consulting : silicon valley, ca > http://cyberwebconsulting.com > Thank you so much Wesley for the tip. I'll look into itemgetter() This is not a homework problem though, but I'm working on a paper in which this is useful. So, it is related to school, but is by no means a homework. -- لا أعرف مظلوما تواطأ الناس علي هضمه ولا زهدوا في إنصافه كالحقيقة.....محمد الغزالي "No victim has ever been more repressed and alienated than the truth" Emad Soliman Nawfal Indiana University, Bloomington --------------------------------------------------------
_______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
