Re: sort string beginning at index?



Oli Filth <catch@xxxxxxxxxxxxxx> wrote in
news:97X_e.2501$Nv6.346@xxxxxxxxxxxxxxxxxxxx:

> Stan McCann said the following on 29/09/2005 19:43:
>> I need some recommendations as to how to go about sorting a string
>> not from the beginning of the string, but from a given index into
>> the string. I am reading a data file into an array using file(),
>> then looping through the string which contains fields seperated by
>> |. Do I have to explode each individual record to sort them using
>> array_multisort()? What I was hoping for was something like sort
>> ($array, SORT_STRING, 15) where 15 is the index into the string to
>> sort on instead of starting at 0. I've been digging through the
>> docs reading about sort and usort and the others but nothing looks
>> like it will work short of using up time and memory creating a
>> multidimensional array to sort.
>
> Well, manipulating data in an array/other data structure is far
> easier than trying to do it in-place in a concatenated string.
>
> I would highly recommend exploding it into an array and sorting the
> array.
>
>

I think you may be misunderstanding which I wish to sort. I read in an
array of:
last|first|phone|email|department|...
and wish to sort the array of records by email address or by department
or by first name, etc. The sort function can sort by last name easily
being the first field in the record. I don't wish to sort each record;
but the records based upon different fields in the records.

--
Stan McCann "Uncle Pirate" http://stanmccann.us/pirate.html
Webmaster/Computer Center Manager, NMSU at Alamogordo
http://alamo.nmsu.edu/ There are 10 kinds of people.
Those that understand binary and those that don't.
.



Relevant Pages

  • Re: A Fast sorting algorithm for almost sorted data
    ... far my compressor has potential but is nowhere near ready. ... It does however make heavy use of sorting. ... which I am currently calling Run sort. ... entire selected run can be added to the sorted output array. ...
    (comp.compression)
  • sort 1-D array of doubles for Olaf Schmidt
    ... A few weeks Olaf Schmidt posted a VB6 routine to sort a 1-D array of strings very fast indeed. ... fastest way to change case of string. ... Dim i As Long, j As Long, Lo As Long, Hi As Long, StPtr As Long ...
    (microsoft.public.vb.general.discussion)
  • Re: Collection Structure
    ... property StringID you want ... where inarr is the String array and outarr is an array of longs containing ... needs to sort the input array keeping track of the original position (I use ...
    (microsoft.public.vb.com)
  • Re: Sorting routine
    ... n RSHIFT shifts n bits. ... in the output array. ... This would be handy for sign sorting of 2's complement. ... So Radix/Distribution sort is about 1.4 times faster than Sedge's Sort. ...
    (comp.lang.forth)
  • Re: How can this be? Why in c# "a-0".CompareTo("a0") returns 1?
    ... It just happens to not sort them the way you think is the best. ... the sorting behavior is defined by the .NET Framework. ... That you consider string sorting to be "basic" simply illustrates how ... than a feature, you will make poor progress in achieving your goals. ...
    (microsoft.public.dotnet.languages.csharp)