Added sort parameter. FIxes bug.