9 Feb 16:50
Re: Utility function to find array items are in ascending order
Keith Goodman <kwgoodman <at> gmail.com>
2010-02-09 15:50:58 GMT
2010-02-09 15:50:58 GMT
On Tue, Feb 9, 2010 at 7:42 AM, Vishal Rana <ranavishal <at> gmail.com> wrote: > Hi, > Is there any utility function to find if values in the array are in > ascending or descending order. > Example: > arr = [1, 2, 4, 6] should return true > arr2 = [1, 0, 2, -2] should return false > Thanks > Vishal I don't know if it is fast but np.diff should do the trick. You can check if all values are less than or equal to zero. Or if all are greater.
RSS Feed