By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,983 Members | 1,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,983 IT Pros & Developers. It's quick & easy.

just array.sort desc simple one dimension with writing comparer???

P: n/a
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
Apr 5 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

Apr 5 '06 #2

P: n/a


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 <=-
Apr 6 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.