Solved

sort list

Posted on 2011-03-14
6
228 Views
Last Modified: 2012-05-11
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

Open in new window

Some are <1, the other >1. than I got false.
0.3492
0.3945

Open in new window

I should get a true.
Thanks.
0
Comment
Question by:zhshqzyc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 22

Expert Comment

by:p_davis
ID: 35130462
bool greaterThanOne = yourList.Exists(num=>num > 1);
0
 
LVL 22

Expert Comment

by:p_davis
ID: 35130474
sorry it should be reversed.


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

Author Comment

by:zhshqzyc
ID: 35130578
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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 62 total points
ID: 35130583
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);

Open in new window

0
 
LVL 22

Assisted Solution

by:p_davis
p_davis earned 63 total points
ID: 35130595
bool same = !yourList.Exists(num=> num < 1 && num > 1);
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35130599
In light of the recent post, modify it to this:
bool result = !(theList.Any(item => item > 1) & theList.Any(item => item < 1));

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question