Sort part of an ArrayList
am 20.11.2007 20:24:55 von Fir5tSight
I have:
ArrayList mPreviousComments = new ArrayList(new string[]{"Please
select a comment:"});
mPreviousComments contains multiple items with the first one being
"Please select a comment:". For example, it contains the following
{"Please select a comment:", "No user intervention is necessary",
"Procedure completed", "Error occured during executing"...}
Now I'll need to sort mPreviousComments in alphabetical order with the
exception that the first item will always be "Please select a
comment:". How to sort the rest of the list? mPreviousComments.Sort()
would sort the entire list.
Re: Sort part of an ArrayList
am 21.11.2007 16:30:25 von Andrew Morton
Curious wrote:
> What parameters to pass to the overload method?
Are you using Notepad (or some other text editor) to create your programs
in, such that you don't have access to the help? In that case you can still
look it up through msdn.microsoft.com.
Andrew
Re: Sort part of an ArrayList
am 22.11.2007 09:30:08 von mangin.nicolas
On Nov 20, 8:24 pm, Curious wrote:
> I have:
>
> ArrayList mPreviousComments = new ArrayList(new string[]{"Please
> select a comment:"});
>
> mPreviousComments contains multiple items with the first one being
> "Please select a comment:". For example, it contains the following
> {"Please select a comment:", "No user intervention is necessary",
> "Procedure completed", "Error occured during executing"...}
>
> Now I'll need to sort mPreviousComments in alphabetical order with the
> exception that the first item will always be "Please select a
> comment:". How to sort the rest of the list? mPreviousComments.Sort()
> would sort the entire list.
Why don't you create a new sort class for your arraylist?
ex:
public class NewSorting : IComparer
{
public int Compare(string x, string y)
{
if(x != "Please select a comment:")
{
blabla....
}
}
}