编辑代码

func mySort(array:inout Array<Any>,sortClosure:(Any,Any)->Bool)->Array<Any>{
    for indexI in array.indices{
        if indexI == array.count-1{
            break
        }
        for indexJ in 0...((array.count-1)-indexI-1){
            if sortClosure (array[indexJ],array[indexJ+1]){

            }
            else{
                array.swapAt(indexJ,indexJ+1)
            }
        }
    }
    return array
}
var array:Array<Any> = [1,4,3,5,7,5,4,2,7]
mySort(array:&array, sortClosure:{(i:Any,nextI:Any)->Bool in
return (i as! Int) < (nextI as! Int)
} )
print(array)