Difference between revisions of "BubbleSortB"

From SCAR Divi Manual
Jump to: navigation, search
(Created page with "==Definition== <source lang="scar" lines="false"> procedure BubbleSortB(var Values: TIntegerArray); </source> ==Availability== SCAR Divi 3.11 > Current ==Description== Uses the...")
 
Line 8: Line 8:
  
 
==Description==
 
==Description==
Uses the [http://en.wikipedia.org/wiki/Bubble_sort bubblesort] sorting algorithm to sort a given set of [[integer]] values specified by the [[TIntegerArray]] '''Values'''. The values will be sorted small->large.
+
Uses the [http://en.wikipedia.org/wiki/Bubble_sort bubblesort] sorting algorithm to sort a given set of [[integer]] values specified by the [[TIntegerArray]] '''Values'''. The values will be sorted large->small.
  
 
==Example==
 
==Example==
Line 17: Line 17:
 
begin
 
begin
 
   Values := [9, 1, 8, 2, 4];
 
   Values := [9, 1, 8, 2, 4];
   BubbleSort(Values);
+
   BubbleSortB(Values);
 
   for i := Low(Values) to High(Values) do
 
   for i := Low(Values) to High(Values) do
 
     WriteLn(Values[i]);
 
     WriteLn(Values[i]);
Line 24: Line 24:
  
 
Output:
 
Output:
 +
9
 +
8
 +
4
 +
2
 
  1
 
  1
2
 
4
 
8
 
9
 
  
 
==See Also==
 
==See Also==
*[[BubbleSortB]]
+
*[[BubbleSort]]
 
*[[QuickSort]]
 
*[[QuickSort]]
  
 
[[Category:Functions]]
 
[[Category:Functions]]
 
[[Category:Math Functions]]
 
[[Category:Math Functions]]

Revision as of 00:26, 2 July 2011

Definition

procedure BubbleSortB(var Values: TIntegerArray);

Availability

SCAR Divi 3.11 > Current

Description

Uses the bubblesort sorting algorithm to sort a given set of integer values specified by the TIntegerArray Values. The values will be sorted large->small.

Example

var
  Values: TIntegerArray;
  i: Integer;
begin
  Values := [9, 1, 8, 2, 4];
  BubbleSortB(Values);
  for i := Low(Values) to High(Values) do
    WriteLn(Values[i]);
end.

Output:

9
8
4
2
1

See Also