为什么排序失败? [英] Why would sort fail?

查看:113
本文介绍了为什么排序失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个库例程,该例程将对嵌套数组进行一些相当复杂的排序.

I'm writing a library routine, which among other things will do some rather complex sorting of nested arrays.

我从文档中看到,所有数组排序功能(包括使用内置比较器的功能)在失败时都可以返回false-但是什么时候会出现这种情况???

I see from the documentation that all the array sort function (including the ones using built-in comparators) can return false on failure - but when would this ever be the case???

推荐答案

当您发送给函数的变量是 NOT 数组时,它将失败. 示例:

It would fail when the variable you send to the function is NOT an array
Example:

asort('Hello');//fails
asort(array(1,2,35,7,2,8,3));//true

这篇关于为什么排序失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆