• Status: Solved
• Priority: Medium
• Security: Public
• Views: 234
• Last Modified:

# sort list

Hello, I have a list(double type). I want to know if all items are greater than 1 or less than 1 at the same time, then a flag is raised.
For ex,
``````0.7776
0.8121
1.27
``````
Some are <1, the other >1. than I got false.
``````0.3492
0.3945
``````
I should get a true.
Thanks.
0
zhshqzyc
Asked:
• 3
• 2
2 Solutions

Commented:
bool greaterThanOne = yourList.Exists(num=>num > 1);
0

Commented:
sorry it should be reversed.

bool greaterThanOne = !yourList.Exists(num=>num > 1);
0

Author Commented:
NO, YOU MISUNDERSTOOD MY QUESTION.
I mean if all great than 1 or all less than 1. I shou get true. The data go the the same direction, towards to >1 or <1.
If mixed direction then get false.
0

Commented:
I think it'd be more along the lines of (take note that there is only 1 ampersand):

``````bool result = theList.Any(item => item > 1) & theList.Any(item => item < 1);
``````
0

Commented:
bool same = !yourList.Exists(num=> num < 1 && num > 1);
0

Commented:
In light of the recent post, modify it to this:
``````bool result = !(theList.Any(item => item > 1) & theList.Any(item => item < 1));
``````
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

## Featured Post

• 3
• 2
Tackle projects and never again get stuck behind a technical roadblock.