We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7231
    • 4,205 Posts
    In that case they seem to be working for me.

    I am using utf8 charset and the edited function in the ditto.class.inc.php looks like this:
    // ---------------------------------------------------
    	// Function: customSort
    	// Sort resource array if advanced sorting is needed
    	// ---------------------------------------------------
    
    	function customSort($data, $fields, $order) {
    		// Covert $fields string to array
    		// user contributed
    		return $data;
    		foreach (explode(',', $fields) as $s)
    			$sortfields[] = trim($s);
    
    		$code = "";
    		for ($c = 0; $c < count($sortfields); $c++)
    			$code .= "\$retval = strnatcmp(\$a['$sortfields[$c]'], \$b['$sortfields[$c]']); if(\$retval) return \$retval; ";
    		$code .= "return \$retval;";
    
    		$params = ($order == 'ASC') ? '$a,$b' : '$b,$a';
    		uasort($data, create_function($params, $code));
    		return $data;
    	}

    Notice the ’return $data’ at the top, this basically returns the same data as was entered thus turning off the function.

    One thing that eventually helped me narrow down the problem was to turn on the ditto debug console and compare output or to try a SQL query directly in the data base and see if it sorts correctly. This way you can see if the problem is a charset issue, ditto issue or whatever.
      [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

      Something is happening here, but you don&#39;t know what it is.
      Do you, Mr. Jones? - [bob dylan]
      • 18397
      • 3,250 Posts
      Try strcasecmp instead of strnatcmp in ditto.class.php.
        • 29076
        • 615 Posts
        No, it didn’t help, but thanks.

        I’ll try to go through this http://dev.mysql.com/doc/refman/5.0/en/charset.html to see if I can find an answer there.

        It could be something about the way mySQL i set to work with non-english caracters, but I don’t know enough about this, so I still need help with the problem in these thread.
          I think, thererfor I am! But what I am, and why...?