44466

php xpath sort alphabetically by field

Question:

I'd like to have a more accurate alphabetical sort for xpath. My current system only sorts the first two characters of the field... I'd like it the order the whole field if possible.

foreach(range('A','Z') AS $firstletter) { foreach(range('a','z') AS $secondletter) { $letters = $firstletter.$secondletter; if($item->xpath("/Entries /Entry[ starts-with( Field42, '".$letters."' ) and Field380 = 'Okay' ]")) {

The Field42 entries are lastnames (ie Brown, Brownstein, Brownwood, Byrnes,..)

Answer1:

I don't think you'll be able to sort using XPath <em>(its goal being to select data -- not sort it)</em>.

So, why not do it in pure-PHP :

<ul><li>First, load all of your nodes to a PHP array</li> <li>And, then, sort that array using one of the functions provided by PHP <ul><li>Such as <a href="http://fr2.php.net/sort" rel="nofollow">sort</a>, <a href="http://fr2.php.net/manual/en/function.asort.php" rel="nofollow">asort</a>, <a href="http://fr2.php.net/manual/en/function.usort.php" rel="nofollow">usort</a>, ...</li> </ul></li> </ul>

Recommend

  • If conditions with hebrew letter [duplicate]
  • Find out if first letter is a vowel prolog
  • Timezone lookup
  • synchronous AJAX post from unload event: how to ensure user sees most up-to-date information from DB
  • TypeScript 2.0 throws errors from excluded files?
  • Sending signal to thread from annother non-process and logging stack not happening
  • Glassfish/Wildfly not failing if @Resource cannot be resolved?
  • Individual Preferences for each item in a ListView?
  • overhead of reserving address space using mmap
  • How do i convert a List to List in c#
  • Python: include entries of a dictionary in the local namespace of a function
  • EventLog logs in Application, even though set to another log
  • Have anyone succeeded in ThinApp'ing Visual Studio?
  • git push origin master denied to user X where x is NOT the user in the local git config
  • Ruby regex to remove all consecutive letters from string
  • Swift string variables localization
  • How to use ResourceDictionary in Windows Phone class library project
  • Add spaces between words in spaceless string
  • Layout design help Android
  • Django model for a Postgres view
  • How can I get the choice “H2” back in the H2 consol?
  • How do I shift the decimal place in Python?
  • Insert new calendar with SyncAdapter- Calendar API Android
  • Excel's Macro-Recorder usage
  • Django: Count of Group Elements
  • Python CGI os.system causing malformed header
  • Can Jackson SerializationFeature be overridden per field or class?
  • How to handle AllServersUnavailable Exception
  • VBA Convert delimiter text file to Excel
  • Jquery - Jquery Wysiwyg return html as a string
  • What do the 'size' numbers mean in the windbg !heap output?
  • Akka Routing: Reply's send to router ends up as dead letters
  • Confusion with PayPal's monthly billing cycle
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • NSLayoutConstraint that would pin a view to the bottom edge of a superview
  • Reading document lines to the user (python)
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • How to push additional view controllers onto NavigationController but keep the TabBar?