Have you tried sorting into groups alphabetically, then changing your sort
to a grouped numeric sort ?
Richard
----- Original Message -----
From: Rajesh Kumar Singh <rajesh_ks@t...>
To: professional vb <pro_vb@p...>
Sent: Thursday, May 18, 2000 6:49 PM
Subject: [pro_vb] Sorting alphanumeric string
>
> Hi !
>
> I have a problem at hand - of sorting alphanumeric strings lexically.
>
> Say I have a column in a table which is six chars wide, eg:
>
> emp_id char(6) : as in Oracle
>
> Now a sample of the data in this column:
>
> 441
> 444
> C1
> c2
> 3
> C12
> 31
> 233
> PT2
> PT8
> H4
> H9
> PT11
> PT10
> C105
> PS6
>
> Now , what I am doing to sort these values is thus :
>
> * Fetch the values of the column into a recordset.
>
> * Start at the beginning of the recordset.
>
> * Check if the value in the column is numeric.
>
> * If the value is numeric, trim the value and store it into a array of
variant
>
> * Get all the numeric values into the array this way.
>
> * Do a numeric comparision of the values in the array and order then in
> ascending
> fashion in the array.
>
> The result for the above set of data will be, which is just fine :
>
> 3
> 31
> 233
> 441
> 444
>
> * Now, go to top of the recordset once again and sieve out the non-numeric
> values
> and store them in another array after trimmimg and changing the case to
> upper.
>
> * Next ( THIS IS THE PROBLEM PART ), I do a sorting of the values in this
> array
> that contains non-numeric ( or alpha-numeric ) values by the method of
> string
> comparision. ie,
>
> ..... if trim(Ucase(c1)) < trim(Ucase(C2)) then.......
>
> this results in a sorted array of non-numeric values which is like this:
>
> C1
> c2
> H4
> H9
> C12
> PS6
> PT2
> PT8
> C105
> PT10
> PT11
>
> I want a method to sort the above in a way that the dictionary sort is
> achieved,
> that is the sorted array of non-numeric values should look like this :
>
> C1
> c2
> C12
> C105
> H4
> H9
> PS6
> PT2
> PT8
> PT10
> PT11
>
>
> Any ideas, folks ?
> Thanks for taking the trouble to go thru this with PATIENCE - something
that
> has gone so much into short supply in this age.
>
> With best regards,
> Rajesh Singh
>