Re: Sorting...

From: Date: Wed, 17 Nov 2004 14:21:45 +0000
Subject: Re: Sorting...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-202298@lists.php.net to get a copy of this message
If each element of the array is a string with those contains, it should be sorted as you want just calling sort function. It will considerate also rest of characters, of course, but the most significative should be the first ones. Another alternative is to wrote a quicksort function in PHP customized by yourself, but I cannot figure out if this will be faster (probably not). Russell P Jones wrote:
I have an array filled with CSV data... array (
        20040310, Title, Author
        20041115, Title, Author
        20040513, Title, Author
     )
where each array element is 1 line from the csv. When I go to print it out, Im going to explode each by , and then print it out the way I like. BUT, I want to sort them all by those first 8 digits, which happen to be the date. Any way to sort an array by the first x characters in its string? This would save a lot on processor time, otherwise Im going to have to pull an array of those characters, sort it, and then run some matching scheme against the CSV data to print it in the order I like - which would be HUGELY processor intensive. Thanks, Russ


« previous php.general (#202298) next »