This blog will describe some of the learning experiences that I have with .NET, some personal projects that I'm working on, and whatever other topics tickle my fancy.
My Blog Links
Wednesday, July 28, 2004
I was recently working on some code, and came upon an instance where I needed to sort an array of integers in descending order. I looked at the Array.Sort method, but that orders them in ascending order by default. So, I started looking for an IComparer implementation that would sort in descending order. Amazingly enough, it doesn't appear that the .NET Framework has a comparer to do that (at least not in v1 or v1.1 -- not sure about v2) .
So, I decided to code one up myself. It's actually a relatively simple concept but very useful. I created a DescendingComparer class that implements the IComparer interface. In its Compare method, I just take the result of the default Comparer class in the .NET Framework and multiple it by -1. This causes the array to be sorted in descending order. So, here's the code:
And yeah, I know I could have just sorted the array and called Array.Reverse to get it in the right order, but that just seemed like a lot of needless operations when this can be done more efficiently with the right comparer class.
Isolaz Acne Treatment Can Get Your Acne Under ControlPost a Comment
It's Not Acne - It's Rosacea
Keratosis Pilaris - Causes, Symptoms and Treatment Methods
Know More About Causes and Treatment of Acne
Laser Acne Scar Removal - Get the New Acne Treatment Now
Laser Acne Scar Treatment - Skin Laser Treatment For Acne Scar Removal
Laser Dermatology - Focused Light to Treat the Skin
Laser Resurfacing - Helping Patients Get Rid of Acne Scars
Laser Scar Removal With Starlux 1540 Fractional Non-Ablative Treatment
Laser Treatment For Acne Treatment, Hair Removal, and Skin Rejuvenation
Learn How Progesterone Cream Can Battle Against Acne
Loma Lux Acne Pill - Review - Does it Really Work?
Looking For Acne Treatment Clinic?
Looking For Acne Treatment? Use Murad
Looking For an Acne Cure? Natural Treatments Are Best
Looking Into Home Remedies For Acne
Makeup for Acne Scars - Hiding as You Heal
Makeup For Acne Scars! Where Effective Cosmetic Products Camouflage Scars, Not Your Life
Male Adult Acne
Mederma Acne Scar Remover - Is It Effective?
Methods to Get Rid of Acne Scarring
Microdermabrasion - Acne Miracle Cure?
Microdermabrasion Alternative - Learn How Sapphire 3 Photo Abrasion Works