Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

sort list

Posted on 2011-03-14
6
Medium Priority
?
230 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
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.

 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 248 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 252 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

722 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