R
Roedy Green
What is the easiest way to determine if a sort actually changed the
order?
I run into this in two situations.
1. do I really need to sort in cases when the data are most likely
already in order? (perhaps just sorting is as fast as trying to bypass
it most of the time).
2. did the sort change anything. Do I have to commit the changed order
to disk?
The obvious solution to (1) is to pairwise compare array exported from
the collection before the sort.
The obvious solution to (2) is compare corresponding elements in
arrays exported before and after the sort with the comparator, or use
(1).
Can you do better than that?
Oracle might add a method isInOrder and/or didOrderChange. The various
sort methods are static, so their is no natural place to put them.
--
Roedy Green Canadian Mind Products
http://mindprod.com
Capitalism has spurred the competition that makes CPUs faster and
faster each year, but the focus on money makes software manufacturers
do some peculiar things like deliberately leaving bugs and deficiencies
in the software so they can soak the customers for upgrades later.
Whether software is easy to use, or never loses data, when the company
has a near monopoly, is almost irrelevant to profits, and therefore
ignored. The manufacturer focuses on cheap gimicks like dancing paper
clips to dazzle naive first-time buyers. The needs of existing
experienced users are almost irrelevant. I see software rental as the
best remedy.
order?
I run into this in two situations.
1. do I really need to sort in cases when the data are most likely
already in order? (perhaps just sorting is as fast as trying to bypass
it most of the time).
2. did the sort change anything. Do I have to commit the changed order
to disk?
The obvious solution to (1) is to pairwise compare array exported from
the collection before the sort.
The obvious solution to (2) is compare corresponding elements in
arrays exported before and after the sort with the comparator, or use
(1).
Can you do better than that?
Oracle might add a method isInOrder and/or didOrderChange. The various
sort methods are static, so their is no natural place to put them.
--
Roedy Green Canadian Mind Products
http://mindprod.com
Capitalism has spurred the competition that makes CPUs faster and
faster each year, but the focus on money makes software manufacturers
do some peculiar things like deliberately leaving bugs and deficiencies
in the software so they can soak the customers for upgrades later.
Whether software is easy to use, or never loses data, when the company
has a near monopoly, is almost irrelevant to profits, and therefore
ignored. The manufacturer focuses on cheap gimicks like dancing paper
clips to dazzle naive first-time buyers. The needs of existing
experienced users are almost irrelevant. I see software rental as the
best remedy.