Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swift冒泡排序测试 #90

Open
platojobs opened this issue Jan 18, 2022 · 1 comment
Open

swift冒泡排序测试 #90

platojobs opened this issue Jan 18, 2022 · 1 comment
Labels
Technology technology

Comments

@platojobs
Copy link
Owner

platojobs commented Jan 18, 2022

总有一天,你会对著过去的伤痛微笑。你会感谢离开你的那个人,他配不上你的爱、你的好、你的痴心。他终究不是命定的那个人。幸好他不是。

—— 张小娴 ​​​​

@platojobs platojobs changed the title 😿 19 Jul 22, 2022
@platojobs platojobs changed the title 19 1 Jul 22, 2022
@platojobs platojobs changed the title 1 test Jul 22, 2022
@platojobs
Copy link
Owner Author

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 arrar: Array<Any> = [ 1,2,4,5,6,2,3,4,1,4,8]

mySort(array: &arrar) { i, next in
    
    (i as! Int) < (next as! Int)
    
}

print(arrar)

@platojobs platojobs changed the title test swift冒泡排序测试 Aug 15, 2022
@platojobs platojobs added the Technology technology label Aug 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Technology technology
Projects
None yet
Development

No branches or pull requests

1 participant