1# sortBy(keyfunc, ascending=true, numPartitions=None)
2
3tmp = [('a', 1), ('b', 2), ('1', 3), ('d', 4), ('2', 5)]
4sc.parallelize(tmp).sortBy(lambda x: x[0]).collect()
5# [('1', 3), ('2', 5), ('a', 1), ('b', 2), ('d', 4)]
6sc.parallelize(tmp).sortBy(lambda x: x[1]).collect()
7# [('a', 1), ('b', 2), ('1', 3), ('d', 4), ('2', 5)]