Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Array sorting on 2 elements
Message
From
29/06/2006 11:44:12
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
29/06/2006 11:37:26
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01132772
Message ID:
01132789
Views:
13
>Hi Cetin,
>User decide which sort to use and after arary is formed I read array again, then search
>in other tables and form some cursor, which is orderd like array is sorted.
>
>In fact my problem is how to properly subscript elements in array of _br rows and 3 columns.
>( multidimensional array - we have had something like that ).
>Regards, Gojko

I had this way back if helps:
Asort(myarray) && Sort on 1st col
axsort(@myarray,1,5,1) && Sort on 5th desc - keep previous sort
axsort(@myarray,5,2)   && Sort on 2nd - keep previous sort

******************
*!* Author:Cbasoz
*!*	function axSort
*!*	Extended array sort
*!*	taSortArray - Array to sort passed by ref
*!*	tnKeepColumn - Column number that's already sorted on
*!*	tnSortColumn - Column to sort
*!*	tnDirection - Omitted or 0 ascending, else descending
******************
Function axsort
  Lparameters taSortArray, tnKeepColumn, tnSortColumn, tnDirection
  tnDirection = iif(empty(m.tnDirection),0,1)
  lnRows = alen(m.taSortArray,1)
  lnRows2Sort=0
  lnSortStart = m.tnSortColumn
  luElem = taSortArray[1,m.tnKeepcolumn]
  For ix=1 to m.lnRows
    If taSortArray[m.ix,m.tnKeepcolumn] # luElem
      Asort(m.taSortArray,m.lnSortStart, m.lnRows2Sort, m.tnDirection)
      lnSortStart = (m.ix-1)*alen(m.taSortArray,2)+m.tnSortColumn
      lnRows2Sort = 1
      luElem = taSortArray[m.ix,m.tnKeepcolumn]
    Else
      lnRows2Sort = m.lnRows2Sort+1
    Endif
  Endfor
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform