Recent

Author Topic: Custom sort, is this a bug?  (Read 1594 times)

alpine

  • Hero Member
  • *****
  • Posts: 1067
Re: Custom sort, is this a bug?
« Reply #15 on: September 05, 2022, 07:38:09 pm »
*snip*
I think there is an error in your loop when the list has an even count of items.
*snip*
You're right, the loop must be less by one:
Code: Pascal  [Select][+][-]
  1.   J := List.Count;
  2.   for I := 0 to Pred(J div 2) do
  3.     List.Exchange(I, Pred(J) - I);

But my question was whether Thaddy wants to just reverse the list by playing tricks with CustomSort.
"I'm sorry Dave, I'm afraid I can't do that."
—HAL 9000

Thaddy

  • Hero Member
  • *****
  • Posts: 14381
  • Sensorship about opinions does not belong here.
Re: Custom sort, is this a bug?
« Reply #16 on: September 21, 2022, 06:51:02 pm »
Well, reversing a list is a common pattern.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

 

TinyPortal © 2005-2018