5
$\begingroup$

Given a list of sets I want to choose the sets whose elements are in ascending order. I think I need to use: Select[list, crit] for this problem, but I could not set the criteria.

For instance,

I have a list:

list = {{1,4,2,3}, {4,2,3,1}, {1,4,8,9}, {1,3,5,7}, {2,4,6,8}, {2,1,3,5}, {4,8,9,10}, {2,7,9,11,13}, {4,1,7,9}}; 

From this list, I would like to obtain the list

{{1,4,8,9}, {1,3,5,7}, {2,4,6,8}, {4,8,9,10}, {2,7,9,11,13}}
$\endgroup$
1
  • $\begingroup$ As an alternative Pick[list, LessEqual[##] & @@@ list] $\endgroup$ Nov 1, 2019 at 17:46

1 Answer 1

8
$\begingroup$

Use OrderedQ:

Select[OrderedQ] @ list

{{1, 4, 8, 9}, {1, 3, 5, 7}, {2, 4, 6, 8}, {4, 8, 9, 10}, {2, 7, 9, 11, 13}}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.