Solved

sort list

Posted on 2011-03-14
6
226 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
.NET Enums [Flags] & Bitwise Design Question 6 51
Header Font Size in Grid View 6 45
Need help with another query 10 52
Which is best Image Resizing Web service 11 38
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Suggested Courses

739 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