Re: sorting, was: Version 3.0 now available!
Brought to you by:
bs_php,
nigelswinson
From: Peter R. <php...@pe...> - 2002-05-14 10:29:04
|
On Monday 13 May 2002 21:48, Nigel Swinson wrote: > > Ok the default order for the results is now doc order. Sorting by other > means probably isn't too difficult anyway, as you can use the usort() > function that takes a callback of two elements that you can then write your > own function to compare elements with. wouldn't disagree with you Nigel, but the problem is surely where there is no element to sort by. If you have in your xml source <a><b><c><a><b><c><b><a> and you say match("//a | //b"), it should return a b a b b a, but it doesn't; it returns the <a>s first, then the <b>s, i.e. a a a b b b. This is wrong, as you are losing information, namely the document order. Of course, as you say, if you want it sorted in some particular sequence, then you can do so using PHP functions. This is similar to the problem we had with the original phpxml retrieving parts of text nodes in the wrong order: once the program has sorted it like this, there is no criteria by which you can get it back to the original sequence. |