4
$\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$
  • $\begingroup$ As an alternative Pick[list, LessEqual[##] & @@@ list] $\endgroup$ – OkkesDulgerci Nov 1 at 17:46
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, privacy policy and cookie policy

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