Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- FlexFile Reference Guide - <b>a_sort()</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 A_SORT()
 Sort all or part of an array in ascending or descending order
-------------------------------------------------------------------------------

 Syntax

    A_SORT(  <aTarget>,
             [<idxPos>],
             [<nCount>],
             [<cOrder>] )

 Arguments

    <aTarget> is the array to be sorted.  A_SORT will not sort a Binary
    "logical" type array.

    <idxPos> is the position in the <aTarget> array to begin the sort.
    If not specified, the default value is one.

    <nCount> is the number of elements beginning at <idxPos> to sort.
    If not specified, all elements are sorted to the end of the array.

    <cOrder> is either "Ascending" or "Descending".  Only the first
    letter is significant.  If not specified, the sort is made
    "Ascending".

 Returns

    None.

 Description

    A_SORT() will sort all or part of a FlexFile array.  If <cOrder>
    is ascending, elements with higher values are stored at the top
    (beginning) of the array.  If <cOrder> is descending, elements
    with lower values are stored at the top of the array.

    Wrapping will occur if <nCount> goes beyond the current row
    pointed to by <idxPos>.

 Examples

    // Declare a two dimensional (C)haracter array
    LOCAL rows, cols, x, y, z

    rows = 10
    cols = 20
    z = 1
    aChar = A_DECLARE( "C", rows, cols )

    // Fill the array with increasing character values.
    FOR x = 1 to rows
       FOR y = 1 to cols
          z++
          A_STORE( aChar, chr(z), A_( x, y ) )
       NEXT
    NEXT

    // Sort the first row in descending order
    A_SORT( aChar, A_( 1, 1 ), cols, 'D' )

    // Show the results
    ? A_RETRIEVE( aChar, A_( 1, 1 ) )    // Result: .
    ? A_RETRIEVE( aChar, A_( 1, 20) )    // Result: .


See Also: A_SCAN()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson