I think this form would make the most sense, rather than having a special value for numPartitions < 0:

    def sortByKey(comp: Comparator[K], ascending: Boolean): JavaPairRDD[K, V] = {
      fromRDD(new OrderedRDDFunctions[K, V, (K, V)](rdd).sortByKey(ascending))
    }

    def sortByKey(comp: Comparator[K], ascending: Boolean, numPartitions: Int): JavaPairRDD[K, V] = {
      fromRDD(new OrderedRDDFunctions[K, V, (K, V)](rdd).sortByKey(ascending, numPartitions))
    }