lib-php: sort after retrieving, use natural sort

(MySQL does not have a natural sort function.) This also needs some
thought on sort priority -- should :rhost have higher priority than
:line or even :host?