scala实战学习-快速排序

def qSort(a:List[Int]):List[Int]={
    if(a.length < 2) 
        a
    else 
        qSort(a.filter(a.head > _)) ++
        a.filter(a.head == _) ++
        qSort(a.filter(a.head < _))
}
qSort(List(9,3,2,6,3,7,8,3,6,9,21))

posted @ 2018-11-29 20:20  枫子_dan  阅读(165)  评论(0编辑  收藏  举报