473,387 Members | 1,420 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Sorting...

Hello, I have a SQL string that pulls data out of a database - I then
calculate completerates based on Hours and # of Completes. I want to sort
this data (FieldID and CompleteRates) by CompleteRate from Highest to lowest.

I have tried an array, but luck. Does anyone have some pointers or
sugguestins that I can get this done?

Thanks In Advance.
MGR
Apr 13 '07 #1
4 2221
Have you looked at doing it it in your SQL statement and sorting the results
as part of the query?

Alternatively, you could use a generic dictionary and simply sort that,
using your FieldID as the Jey and CompleteRates as the item.

Dictionary<string, strings = new Dictionary<string, string>();
s.Add("1", "a Item");
s.Add("2", "c Item");
s.Add("3", "b Item");

List<KeyValuePair<string, string>myList = new List<KeyValuePair<string,
string>>(s);
myList.Sort(
delegate(KeyValuePair<string, stringfirstPair, KeyValuePair<string,
stringnextPair){
return firstPair.Value.CompareTo(nextPair.Value);
}
);

foreach (KeyValuePair<string, stringmyKey in myList) {
Response.Write(myKey.Key + " " + myKey.Value);
}

Regards
John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"MGRideout" <MG*******@discussions.microsoft.comwrote in message
news:90**********************************@microsof t.com...
Hello, I have a SQL string that pulls data out of a database - I then
calculate completerates based on Hours and # of Completes. I want to sort
this data (FieldID and CompleteRates) by CompleteRate from Highest to
lowest.

I have tried an array, but luck. Does anyone have some pointers or
sugguestins that I can get this done?

Thanks In Advance.
MGR

Apr 13 '07 #2
Thanks for the reply John. I am using VB.NET, would this be the same sytax.
Thanks,
MGR

"John Timney (MVP)" wrote:
Have you looked at doing it it in your SQL statement and sorting the results
as part of the query?

Alternatively, you could use a generic dictionary and simply sort that,
using your FieldID as the Jey and CompleteRates as the item.

Dictionary<string, strings = new Dictionary<string, string>();
s.Add("1", "a Item");
s.Add("2", "c Item");
s.Add("3", "b Item");

List<KeyValuePair<string, string>myList = new List<KeyValuePair<string,
string>>(s);
myList.Sort(
delegate(KeyValuePair<string, stringfirstPair, KeyValuePair<string,
stringnextPair){
return firstPair.Value.CompareTo(nextPair.Value);
}
);

foreach (KeyValuePair<string, stringmyKey in myList) {
Response.Write(myKey.Key + " " + myKey.Value);
}

Regards
John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog
"MGRideout" <MG*******@discussions.microsoft.comwrote in message
news:90**********************************@microsof t.com...
Hello, I have a SQL string that pulls data out of a database - I then
calculate completerates based on Hours and # of Completes. I want to sort
this data (FieldID and CompleteRates) by CompleteRate from Highest to
lowest.

I have tried an array, but luck. Does anyone have some pointers or
sugguestins that I can get this done?

Thanks In Advance.
MGR


Apr 13 '07 #3
(ooops . pressed send to early )
6/19/2006

Advanced IComparer // Sorting on Multiple Values

http://sholliday.spaces.live.com/blog/

"MGRideout" <MG*******@discussions.microsoft.comwrote in message
news:90**********************************@microsof t.com...
Hello, I have a SQL string that pulls data out of a database - I then
calculate completerates based on Hours and # of Completes. I want to sort
this data (FieldID and CompleteRates) by CompleteRate from Highest to
lowest.
>
I have tried an array, but luck. Does anyone have some pointers or
sugguestins that I can get this done?

Thanks In Advance.
MGR

Apr 27 '07 #4

You can look at a IComparer example at:


"MGRideout" <MG*******@discussions.microsoft.comwrote in message
news:90**********************************@microsof t.com...
Hello, I have a SQL string that pulls data out of a database - I then
calculate completerates based on Hours and # of Completes. I want to sort
this data (FieldID and CompleteRates) by CompleteRate from Highest to
lowest.
>
I have tried an array, but luck. Does anyone have some pointers or
sugguestins that I can get this done?

Thanks In Advance.
MGR

Apr 27 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: dont bother | last post by:
This is really driving me crazy. I have a dictionary feature_vectors{}. I try to sort its keys using #apply sorting on feature_vectors sorted_feature_vector=feature_vectors.keys()...
0
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update...
7
by: Federico G. Babelis | last post by:
Hi All: I have this line of code, but the syntax check in VB.NET 2003 and also in VB.NET 2005 Beta 2 shows as unknown: Dim local4 As Byte Fixed(local4 = AddressOf dest(offset)) ...
19
by: Owen T. Soroke | last post by:
Using VB.NET I have a ListView with several columns. Two columns contain integer values, while the remaining contain string values. I am confused as to how I would provide functionality to...
10
by: Sjaakie | last post by:
Hi, I'm, what it turns out to be, fooling around with 3-tier design. At several websites people get really enthusiastic about using custom dataobjects instead of datasets/-tables. While trying to...
4
by: Ambica Jain | last post by:
Hi, I want custom sorting on some of the columns in the datagrid. And i am able to do the same by overriding MouseDown event. However, i need to rebind my datatable to reflect the changes in...
7
by: Kamal | last post by:
Hello all, I have a very simple html table with collapsible rows and sorting capabilities. The collapsible row is hidden with css rule (display:none). When one clicks in the left of the...
1
KevinADC
by: KevinADC | last post by:
Introduction In part one we discussed the default sort function. In part two we will discuss more advanced techniques you can use to sort data. Some of the techniques might introduce unfamiliar...
5
by: lemlimlee | last post by:
hello, this is the task i need to do: For this task, you are to develop a Java program that allows a user to search or sort an array of numbers using an algorithm that the user chooses. The...
5
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.