You should provide more details. Assuming you are using OOo Basic a simple
bubble sort might be OK. Wikipedia gives the following pseudo code:
procedure bubbleSort( A : list of sortable items )
n = length(A)
for (i = 0; i < n; i++)
/* back through the area bringing smallest remaining element to
position i */
for (j = n-1; j > i; j--)
if A[j-1] > A[j] then
swap(A[j-1], A[j])
end if
end for
end for
end procedure
Assuming your n-line array will fit in the memory available parse the first
five characters to a separate variable and replace the swap line with
something like:
Dim X1 as long
Dim X2 as Long
Dim Temp as Long
X1 = Left$(A(j-1)
X2 = Left$(A (j)
If X1 > X2 then
'swap line
Temp = A(j)
A(j) = A(j-1)
A(j) = Temp
End If
A bubble sort is inefficient but the code is simple
Hope this helps
Harold Hauge
On Fri, Apr 15, 2011 at 5:14 AM, john d. herron
<[email protected]>wrote:
> Hi, all.
> In a Basic procedure i'm building an n-line array in which the first
> element of each line is a five-digit string.
> Is there a way to sort the array on that five-digit string ? Couldn't find
> anything helpful in the manual.
> Thanks for helping.
>
> john herron
> _________________________________________
> Linux Mint 9 xfce
> 2.6.32-21 generic
> OpenOffice v 3.2.0 (m12-Bld 9483)
>
>
--
-----------------------------------------------------------------
To unsubscribe send email to [email protected]
For additional commands send email to [email protected]
with Subject: help