Improve sort order by looking at php code