473,395 Members | 1,999 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,395 software developers and data experts.

doubt in csharp

Hi,

I have one doubt in c_sharp. Please let me know is there any
Collection or Dictonery having the Sort facility. I want to sort a list of
Numbers. how to do that? For Example i am going to store some value in
either Hash dictonery or ArrayList... With out writing code is there any
way to Sort?

Note: Array List is not working fine.

Regards,
R.Baskar
Nov 15 '05 #1
5 2114
Baskar RajaSekharan <rb*@srasys.co.in> wrote:
I have one doubt in c_sharp. Please let me know is there any
Collection or Dictonery having the Sort facility. I want to sort a list of
Numbers. how to do that? For Example i am going to store some value in
either Hash dictonery or ArrayList... With out writing code is there any
way to Sort?
Yes: ArrayList.Sort.
Note: Array List is not working fine.


That suggests you're misusing it. Could you give an example?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2
On 11/6/2003 2:30 PM, Baskar RajaSekharan wrote:
I have one doubt in c_sharp. Please let me know is there any
Collection or Dictonery having the Sort facility. I want to sort a list of
Numbers. how to do that? For Example i am going to store some value in
either Hash dictonery or ArrayList... With out writing code is there any
way to Sort?

Note: Array List is not working fine.


What do you mean it doesn't work fine? What Sort(..) method do you use?
Are you using right IComparer? Are the objects you want to sort IComparable?

regards,
Bogdan

Nov 15 '05 #3
Hi,

ArrayList.Sort() should do the trick, now remember that the elements of the
arraylist MUST implement IComparable.

These are the things I would check:
1- that all elements of the list are of the same type.
2- that this type implement IComparable ( you say that they are numbers, if
you mean with this that they are "int" you are ok with this).

if the above is true then it should work fine, otherwise post the code
and/or the error you are getting
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Baskar RajaSekharan" <rb*@srasys.co.in> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,

I have one doubt in c_sharp. Please let me know is there any
Collection or Dictonery having the Sort facility. I want to sort a list of Numbers. how to do that? For Example i am going to store some value in
either Hash dictonery or ArrayList... With out writing code is there any
way to Sort?

Note: Array List is not working fine.

Regards,
R.Baskar

Nov 15 '05 #4
100
Sorted collections are: ArrayList (I don't know what you mean by *it is not
working fine* and SortedList if you need dictionary like collection.

HTH
B\rgds
100

"Baskar RajaSekharan" <rb*@srasys.co.in> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,

I have one doubt in c_sharp. Please let me know is there any
Collection or Dictonery having the Sort facility. I want to sort a list of Numbers. how to do that? For Example i am going to store some value in
either Hash dictonery or ArrayList... With out writing code is there any
way to Sort?

Note: Array List is not working fine.

Regards,
R.Baskar

Nov 15 '05 #5
OR,

in addition to all these other good suggestions, you could use this gem:
SortedList.

It's a hybrid between an arraylist and dictionary object which keeps its
contents ordered so you don't have to explicitly call a sort method.

When items indexing is used, it behaves like an array, otherwise it behaves
like a hash.
regards

--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"Baskar RajaSekharan" <rb*@srasys.co.in> wrote in message
news:#d**************@TK2MSFTNGP12.phx.gbl...
Hi,

I have one doubt in c_sharp. Please let me know is there any
Collection or Dictonery having the Sort facility. I want to sort a list of Numbers. how to do that? For Example i am going to store some value in
either Hash dictonery or ArrayList... With out writing code is there any
way to Sort?

Note: Array List is not working fine.

Regards,
R.Baskar

Nov 15 '05 #6

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

Similar topics

0
by: Baskar RajaSekharan | last post by:
Please clarify My doubt.. 1) How to find out whether the component devekopment in Csharp is in Relase Mode or Run Mode? 2) Like Class Id in C++ , what the Unique Id for C-shap Component?
4
by: Baskar RajaSekharan | last post by:
Please clarify My doubt.. 1) How to find out whether the component devekopment in Csharp is in Relase Mode or Run Mode? 2) Like Class Id in C++ , what the Unique Id for C-shap Component?
6
by: Baskar RajaSekharan | last post by:
In C-sharp, I wnat to know whether the Component is compiled in Debug Mode or Run Mode through Code. How is it possible? Is there any way to Access the Config file and check? Please let me know...
2
by: Baskar RajaSekharan | last post by:
Hi, I have a C# usercontrol which has an OCX in addition to combo, textboxes etc. i need to print the usercontrol. How could this be acheived? In VB there is one method called PrintForm . ...
7
by: Peter Smirnov | last post by:
Sorry for this newbie question but as far as I heard one need at least VisualStudio to develop CSharp applications. Is this correct? Are there otherwise some command line tools like javac.exe and...
6
by: Luca | last post by:
I have a doubt: is it dangerous to create widgets out of the main thread, or it is dangerous to call methods of a widgets out of the thread which created it? or both? TIA Perry
2
by: rajesh | last post by:
Hi, I have some doubts about threadpool. I have a function which does some calculation for long time and writes the results to a file. Since I have to do multiple call to the same functions, I...
2
by: news.microsoft.com | last post by:
Hi: I work in Csharp's parser files by LEX/YACC.Now I have only CSharp-lex.l and CSharp.y file,but they not have CSharp'comment Parse. this is a part of CSharp-lex.l. ........................
2
by: CSharp | last post by:
Hello all, I have in my project this user control I made: public class PollControl : System.Web.UI.UserControl I have properties on its code-behind like: ****************************...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.