Difference between revisions of "SortTPA"

From SCAR Divi Manual
Jump to: navigation, search
(Created page with "==Definition== <source lang="scar" lines="false"> procedure SortTPA(var TPA: TPointArray); </source> ==Availability== SCAR Divi 3.26 > Current ==Description== Sorts a given [[T...")
 
 
(9 intermediate revisions by the same user not shown)
Line 5: Line 5:
  
 
==Availability==
 
==Availability==
SCAR Divi 3.26 > Current
+
SCAR Divi 3.28 > Current
 +
 
 +
===Aliases===
 +
*TPASort (SCAR Divi 3.26 > 3.37)
 +
 
 +
===Notes===
 +
*Before 3.37.02, this function threw exceptions for points with large coordinate values (over +/- 30000 in either direction from 0)
  
 
==Description==
 
==Description==
Line 18: Line 24:
 
   TPA := [Point(2, 2), Point(0, 0), Point(5, 10), Point(0, 0)];
 
   TPA := [Point(2, 2), Point(0, 0), Point(5, 10), Point(0, 0)];
 
   SortTPA(TPA);
 
   SortTPA(TPA);
   WriteLn('TPointArray: ' + TPAToStr(TPA));
+
   WriteLn(TPAToStr(TPA));
 
end.
 
end.
 
</source>
 
</source>
  
 
Output:
 
Output:
  TPointArray: (0,0);(0,0);(2,2);(5,10)
+
  (0,0);(0,0);(2,2);(5,10)
  
 
==See Also==
 
==See Also==
 
*[[SortTPAEx]]
 
*[[SortTPAEx]]
*[[ATPASortBySize]]
+
*[[SortTPAByRow]]
 +
*[[SortTPASpiral]]
 +
*[[SortATPABySize]]
  
 
[[Category:Functions]]
 
[[Category:Functions]]
 
[[Category:TPA Functions]]
 
[[Category:TPA Functions]]
 
[[Category:Array Functions]]
 
[[Category:Array Functions]]

Latest revision as of 14:09, 26 November 2012

Definition

procedure SortTPA(var TPA: TPointArray);

Availability

SCAR Divi 3.28 > Current

Aliases

  • TPASort (SCAR Divi 3.26 > 3.37)

Notes

  • Before 3.37.02, this function threw exceptions for points with large coordinate values (over +/- 30000 in either direction from 0)

Description

Sorts a given TPointArray TPA by distance from the origin (0, 0) using the fast ShellSort algorithm. An extended function with additional functionality is available as SortTPAEx.

Example

var
  TPA: TPointArray;

begin
  TPA := [Point(2, 2), Point(0, 0), Point(5, 10), Point(0, 0)];
  SortTPA(TPA);
  WriteLn(TPAToStr(TPA));
end.

Output:

(0,0);(0,0);(2,2);(5,10)

See Also