0

am assigned to sort and display Record of coaches hourly pay rate in ascending order from 0 Dollars to 500 Dollars, For example, I have 3 coaches the first coach hourly pay rate is 250 dollars the second is 140 dollars and the third is 320 dollars and those 3 coaches records are in one txt.file and not sorted

Hany
  • 5
  • 3
  • 1
    It would be helpful if you could provide code example of what you have tried. – Peeraponw Jan 14 '21 at 08:58
  • 1
    Example data will also be helpful. – Yang Liu Jan 14 '21 at 09:09
  • Does this answer your question? [How do I sort a text file by three columns with a specific order to those columns in Python?](https://stackoverflow.com/questions/48726710/how-do-i-sort-a-text-file-by-three-columns-with-a-specific-order-to-those-column) – Pygirl Jan 14 '21 at 09:11
  • syntax will be like this: `lines.sort(key = lambda x: (x[1], x[2], int(x[3])))` If you want descending order then place `-` like this `lines.sort(key = lambda x: (x[1], -x[2], int(x[3])))` ===> `x[2] --> descending` – Pygirl Jan 14 '21 at 09:14

0 Answers0