Re: Did the sort do anything?
- From: Cindy <c.thurston@xxxxxxxxxxxxxxxxx>
- Date: Mon, 07 Nov 2011 22:02:05 -0500
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).
.
- Follow-Ups:
- Re: Did the sort do anything?
- From: Cindy
- Re: Did the sort do anything?
- References:
- Did the sort do anything?
- From: Roedy Green
- Re: Did the sort do anything?
- From: Dagon
- Did the sort do anything?
- Prev by Date: Re: unicode
- Next by Date: Re: Immutable Datastructures with good Sharing
- Previous by thread: Re: Did the sort do anything?
- Next by thread: Re: Did the sort do anything?
- Index(es):
Relevant Pages
|