[Numpy-discussion] Utility function to find array items are in ascending order

Vishal Rana ranavishal@gmail....
Tue Feb 9 10:53:16 CST 2010


Thanks
On Tue, Feb 9, 2010 at 7:51 AM, Brent Pedersen <bpederse@gmail.com> wrote:

> On Tue, Feb 9, 2010 at 7:42 AM, Vishal Rana <ranavishal@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
> >
> > _______________________________________________
> > NumPy-Discussion mailing list
> > NumPy-Discussion@scipy.org
> > http://mail.scipy.org/mailman/listinfo/numpy-discussion
> >
> >
>
> i dont know if there's a utility function, but i'd use:
>
>  >>> np.all(a[1:] >= a[:-1])
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20100209/1f35ad76/attachment.html 


More information about the NumPy-Discussion mailing list