Re: Did the sort do anything?



On 07/11/2011 3:50 PM, Dagon wrote:
Note that #1 is a different question than you asked. "would a sort
change the order" is not the same as "did a sort change the order".

Isn't the simplest method (assuming a stable sort algorithm is/would be used) just to grovel over the input checking that thing[n] < thing[n+1] and returning true immediately if not, and false if the end of the input is reached? I.e., "is it already sorted?" seems equivalent to "would a sort change the order?" when the sort would be a stable sort. For "did the sort change the order?" just copy the input, sort, and then check the unsorted copy in like fashion; or check the input, store the result, and sort (or check the input, store the result, and sort iff the result says the input's not sorted).
.



Relevant Pages

  • Re: Can sort change a lf to crlf?
    ... the sort can do what you are looking for. ... Can sort change a lf to crlf? ... send email to listserv@xxxxxxxxxxx with the message: GET IBM-MAIN INFO ... Search the archives at http://bama.ua.edu/archives/ibm-main.html ...
    (bit.listserv.ibm-main)
  • [8FOLD] Template #3
    ... "You lead a very eventful life, don't you, Mr. Kidman?" ... lunatics collapsing in the middle of your store... ... threats have some sort of motivation behind them. ...
    (rec.arts.comics.creative)
  • Re: Bad feelings in Wickes
    ... to sort it out. ... insisted that I should approach the exit without the carrier bag, ... test if the machine would beep. ... A few years My brother and I went into a Wicks Store and bought a large ...
    (uk.legal)
  • C 128s ROM socket
    ... sort of a new topic, so I didn't reply to that. ... I've thought about that ROM socket in the C128 a lot and have on occasion ... So I'm hoping to use something on the IEC port to store more ... up trying to read/write to a serial flash ram chip via the user port.. ...
    (comp.sys.cbm)
  • Re: all this talk of clothing made in china...
    ... USA." and in her store, she's only going to sell items that are made ... and just the sort of person that should think about joining the ... I was brought up by parents (mother, mostly) who instilled me with all ...
    (uk.people.support.depression)