Re: sort string beginning at index?



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.


-- Oli .



Relevant Pages

  • 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: About word frequency
    ... Use the split function to turn the string into an array. ... Sort the array. ... For each sLine in aList ...
    (microsoft.public.scripting.vbscript)
  • Re: more on reading csv file into access
    ... Of course you get an error, you are assigning an array to a single string, ... how on earth is it supposed to output the array, there is no magic where VB ... Dim dataVals() As String ... data file are a mixture of numbers and text fields. ...
    (microsoft.public.vb.general.discussion)
  • Re: Quick method to sort a list of strings?
    ... 'split string into an array around so each line is a seperate item ... the cell may represent the number of purchases by ... I do not have all the these comments stored in an array ... separate entities and sort them in alpha-numeric order? ...
    (microsoft.public.excel.programming)