Implemented sortedpd.