Is this what you want? https://stackoverflow.com/a/2828121
Also using pandas for this is the way to go: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.sort_values.html On Wed, Dec 18, 2019 at 9:09 AM Savin Beniwal <[email protected]> wrote: > Hi all > After spending many hours on Google, I came here to get your suggestions > regarding the following query: > > I have a text file of five columns. I want to sort the second column > (ascending order) by keeping the other column adjust itself as per original > one entity of 2nd column. I'm able to sort only one column in python but > not able to keep the other column adjust itself. > I need the output as shown below: > 2 0.1 0.5 6 0 > 1 0.2 0.5 4 5 > 3 0.8 0.2 5 2 > 5 0.8 0.2 5 2 > 5 2.0 0.2 3 5 > 8 3.0 0.9 3 6 > > > Thank you for your time and reply (in advance). > > -- > You received this message because you are subscribed to the Google Groups > "spyder" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/spyderlib/f2824e35-bafe-478a-bf75-bf54bc81de75%40googlegroups.com > <https://groups.google.com/d/msgid/spyderlib/f2824e35-bafe-478a-bf75-bf54bc81de75%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "spyder" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/spyderlib/CACx0QwOGPEHQSs7WhgVK8WR1RWmugiREXTpyk_TsSXjQaXJsog%40mail.gmail.com.
