Hey guys, I came across little bit more complicated sorting function. I have results :
Merginos (Females)
111 Roma Liepa 0 51 20
115 Rima Joana 1 29 23
Vaikinai (Males)
256 Zigmas Nosis 0 20 6
213 Petras A. Petraitis 0 38 10
255 Rytis Uosis Ainis 0 39 50
What I need to do is to sort these by their times (starting lowest and increasing) and their gender. Now, luckily, this exercise came out perfectly "sorted". But let's say I'd have like
Merginos
115 Rima Joana 1 29 23
111 Roma Liepa 0 51 20
Vaikinai
213 Petras A. Petraitis 0 38 10
256 Zigmas Nosis 0 20 6
255 Rytis Uosis Ainis 0 39 50
how would I sort that ? I assume you don't need the whole code but I'm gonna link my whole void function (which finds time difference and prints answers)
are you asking how to do a then-by sort?
it works like you would do it in excel, or by hand...
you sort the list once by gender, for the output you asked.
take that sorted list and split it into 2 new lists, one for males, one for females. Sort the two new lists by time.
generate output:
print males, print all the males in order by time, print females, print them by time...
*because* the initial sort by gender is currently binary, you can avoid the above work and make it more efficient, but that would not work if you had all the PC genders for example, its too many to do that way.
In your binary gender case, just sort by time. After sorting by time, when outputting, pass over the data once for males and a second time for females, only print the one you want each pass, or if you need them split out to do later processing, do a one pass reverse merge type split.