SORT

Aus MCS Wiki AVR
(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
(Created page with "= <span class="f_Header">Action</span> = Sorts an array in ascending order. <span style="font-family: Arial;"> </span> <span style="font-family: Arial;"> </span> ...")
 
 
Zeile 36: Zeile 36:
 
<span style="font-family: Arial;">&nbsp;</span>
 
<span style="font-family: Arial;">&nbsp;</span>
  
Sorting is implemented for byte, word and integer arrays.
+
Sorting is implemented for BYTE, WORD, INTEGER, LONG and DWORD arrays.
  
 
The routines are located in mcs.lib.
 
The routines are located in mcs.lib.

Aktuelle Version vom 13. Dezember 2014, 23:13 Uhr

Inhaltsverzeichnis

Action

Sorts an array in ascending order.

 

 

Syntax

SORT array() [,elements]

 

 

Remarks

array()

The first element of the array to sort.

elements

The number of elements to sort. This is an optional value. By default all elements will be sorted.

 

Sorting is implemented for BYTE, WORD, INTEGER, LONG and DWORD arrays.

The routines are located in mcs.lib.

 

 

 

See also

NONE

 

 

Example


'-------------------------------------------------------------------------------
' SORT.BAS
' (c) 1995-2011 , MCS Electronics
' This demo demonstrates the SORT statement. It will sort an array
' sort supports, byte, integer and word arrays at the first release
'------------------------------------------------------------------------------
$regfile = "m88def.dat"
$crystal = 8000000
$hwstack = 16
$swstack = 8
$framesize = 30
 
'Dim some arrays
Dim B(10) As Byte , I(10) As Integer , W(10) As Word
Dim J As Byte
 
'point to data
Restore Arraydata
 
'read the data
For J = 1 To 10
 Read B(j)
Next
'read the words
For J = 1 To 10
 Read W(j)
Next
'read the integers
For J = 1 To 10
 Read I(j)
Next
 
'now sort the arrays
Sort B(1) , 10 ' 10 elements
Sort W(1) ' all elements
Sort I(1)
 
'and show the result
For J = 1 To 10
 Print J ; " " ; B(j) ; " " ; W(j) ; " " ; I(j)
Next
End
 
 
 
 
Arraydata:
Data 1 , 4 , 8 , 9 , 2 , 5 , 3 , 7 , 6 , 4
Data 1000% , 101% , 1% , 400% , 30000% , 20000% , 15000% , 0% , 999% , 111%
Data -1000% , 101% , -1% , 400% , 30000% , 2000% , -15000% , 0% , 999% , 111%

Languages   English Deutsch  
Meine Werkzeuge
Namensräume
Varianten
Aktionen
Navigation
In anderen Sprachen
Sprache