i build a string[]
string eProduct = "#blah#ablah#bbbb";
StringBuilder sb = new StringBuilder(eProduct);
eProduct = sb.Replace("#","").ToString();
string[] aProducts= eProduct.Split(';');
then I sort asc or desc
Array.Sort so simple, is there not some just as simple without writing
comparer etc
just to Array.Sort DESC?
if( (numberDiv%2) != 0 ){
//sort desc PLEASE
Array.Sort(aProducts, DESC); ???????? does not work
else
//sort asc
Array.Sort(aProducts);
--
cindy 2 4359
Cindy,
Unfortunately, no, there is not. However, writing such an
implementation is completely trivial. You could do it in less than five
minutes. Just negate the value returned to you by the static Compare method
on string (when passing the two strings).
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"cindy" <cm****@nospam.nospam> wrote in message
news:AE**********************************@microsof t.com... i build a string[]
string eProduct = "#blah#ablah#bbbb"; StringBuilder sb = new StringBuilder(eProduct); eProduct = sb.Replace("#","").ToString(); string[] aProducts= eProduct.Split(';');
then I sort asc or desc Array.Sort so simple, is there not some just as simple without writing comparer etc just to Array.Sort DESC?
if( (numberDiv%2) != 0 ){
//sort desc PLEASE
Array.Sort(aProducts, DESC); ???????? does not work else //sort asc Array.Sort(aProducts);
-- cindy
Nicholas Paldino [.NET/C# MVP] wrote: Cindy,
Unfortunately, no, there is not. However, writing such an implementation is completely trivial. You could do it in less than five minutes. Just negate the value returned to you by the static Compare method on string (when passing the two strings).
Another implementation would be to simply:
1. sort
2. reverse
--
Helge Jensen
mailto:he**********@slog.dk
sip:he**********@slog.dk
-=> Sebastian cover-music: http://ungdomshus.nu <=- This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mark |
last post by:
Assume you have a strongly typed collection of a class called Person. The
strongly typed collection implements IEnumerable so it can be databound to a
server control like a DataGrid. The Person...
|
by: Niklas Uhlin |
last post by:
Why does the code below output this:
"v a" (118,32,97)
"w a" (119,32,97)
"v b" (118,32,98)
"w b" (119,32,98)
"v c" (118,32,99)
"w c" (119,32,99)
and not this (as one would expect if...
|
by: Arjen |
last post by:
Hi,
I need to add this inside an array:
1 3
2 4
3 2
4 5
5 1
I think of using this:
|
by: tg |
last post by:
How can I sort a two-dimension array on the first dimension in the array?
If there's not a way to do it, how can I return the values of the first
dimension so that I can sort the values myself...
|
by: Jurgen Oerlemans |
last post by:
Hello, I want to make an array of filenames in a directory.
I started with the following code:
Dim DirInfo As IO.DirectoryInfo = New IO.DirectoryInfo("N:\queues\jurgen\")
Dim FileInfo As...
|
by: Jack |
last post by:
Hello,
I have an array that won't sort correctly:
Dim MyArrayList As New ArrayList
Dim MyString As String = "5,3,44,22,20,2,40,1,32.50"
MyArrayList.AddRange(MyString .Split(","c))
|
by: Amar |
last post by:
Hi,
I have a generic list with a some objects of a particular class in it.
I have implemented a IComparer for the the class and pass it to the
List.
The list.sort method works fine when the value...
|
by: Paul E Collins |
last post by:
char c = { 'a', 'b', 'c', 'A', 'B', 'C' };
Array.Sort(c, CaseInsensitiveComparer.Default);
After this, c is ordered { 'A', 'B', 'C', 'a', 'b', 'c' }.
I want letters to be sorted together...
|
by: JC |
last post by:
Hi all,
I have scoured the internet for articles on sorting multi-dimensional
arrays of generic types e.g. T using the IComparer<Tinterface
and have run into a real roadblack. There does not...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |