Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Python by (12.7k points)

Is there a pythonic approach to check if a rundown is as of now arranged in ASC or DESC 

listtimestamps = [1, 2, 3, 5, 6, 7]

something like isttimestamps.isSorted() which returns True or False

I need to include a rundown of timestamps for certain messages and check if the exchanges showed up in the right request.

1 Answer

0 votes
by (26.4k points)

Check the below code:

all(l[i] <= l[i+1] for i in xrange(len(l)-1))

For python 3:

all(l[i] <= l[i+1] for i in range(len(l)-1))

Are you pretty much interested to learn python in detail? Come and join the python training course to gain more knowledge.

For more details, do check out the below video tutorial...

Related questions

0 votes
2 answers
asked Oct 3, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
0 votes
1 answer

Browse Categories

...