Fixing bug when sort key and sort order where null