Zithromax For Sale

Scenario: you have a List<string> Zithromax For Sale, collection where the contents could be alpha, numeric, or alphanumeric. If you just sort the collection using the built-in Sort() method, Zithromax use, Japan, craiglist, ebay, overseas, paypal, it will use string.CompareTo(), treating each item in the collection as a string, Zithromax price, coupon. Purchase Zithromax for sale, Thus a collection with the following values ["1", "44", Zithromax blogs, Generic Zithromax, "22", 4", Zithromax photos, Kjøpe Zithromax på nett, köpa Zithromax online, "5"] will end up being sorted as ["1", "22", online buying Zithromax hcl, Zithromax images, "4", "44", Zithromax from canada, Zithromax online cod, "5"] - even though you might want the items to be treated as numbers (in which case they would be sorted as ["1", "4", real brand Zithromax online, Purchase Zithromax online no prescription, "5", "22", Zithromax mg, Order Zithromax from United States pharmacy, "44"].

The solution to this is to use a custom comparer class, Zithromax dosage. Purchase Zithromax online, I put the following together:

public class NumericStringSort : IComparer {

int IComparer.Compare(string a, string b) {
decimal aDec;
decimal bDec;
if (decimal.TryParse(a, purchase Zithromax, Zithromax over the counter, out aDec) && decimal.TryParse(b, out bDec)) {
return aDec.CompareTo(bDec);
} else {
return a.CompareTo(b);
}
}

public static IComparer NumericStringSorter() {
return (IComparer) new NumericStringSort();
}
}


As you can see, rx free Zithromax, Buy Zithromax no prescription, the class implements the IComparer interface. If both of the strings can be converted into decimals, cheap Zithromax no rx, Zithromax recreational, then the decimal comparison is used. Otherwise the string comparison is used, low dose Zithromax. Zithromax brand name, You can see a usage example through the following set of unit tests (as you can see, it also handles mixed alphanumeric sets gracefully, is Zithromax addictive, Zithromax schedule, sorting all numeric items to the front of the list in numeric order, followed by all alpha entries in alphabetical order):
[TestFixture]
public class NumericStringSortTests {

[Test]
public void TestNumericSort_AllNumeric() {
List items = new List { "1", Zithromax used for, Australia, uk, us, usa, "44", "22", my Zithromax experience, Zithromax gel, ointment, cream, pill, spray, continuous-release, extended-release, "4", "5" };
items.Sort(NumericStringSort.NumericStringSorter());
List expectedItems = new List { "1", Zithromax without a prescription, Online buying Zithromax, "4", "5", cheap Zithromax, Order Zithromax from mexican pharmacy, "22", "44" };
Assert.IsTrue(items.SequenceEqual(expectedItems));
}

[Test]
public void TestNumericSort_MixesAlphaNumeric() {
List items = new List { "a", online buy Zithromax without a prescription, Zithromax price, "c", "d", Zithromax duration, Zithromax pics, "b", "1", "2", "22", "3" };
items.Sort(NumericStringSort.NumericStringSorter());
List expectedItems = new List { "1", "2", "3", "22", "a", "b", "c", "d" };
Assert.IsTrue(items.SequenceEqual(expectedItems));
}

[Test]
public void TestNumericSort_AllAlpha() {
List items = new List { "a", "c", "d", "b" };
items.Sort(NumericStringSort.NumericStringSorter());
List expectedItems = new List { "a", "b", "c", "d" };
Assert.IsTrue(items.SequenceEqual(expectedItems));
}
}


This is something that I have needed on previous occasions - perhaps it may be of use to someone else.

Similar posts: Buy Periactin Without Prescription. Buy Methotrexate Without Prescription. Buy Macrobid Without Prescription. Cephalexin For Sale. Quinine For Sale. Tramadol dosage. What is Ketoconazole Cream. Where can i buy cheapest Diclofenac online. Atarax price. Comprar en línea Accutane, comprar Accutane baratos.
Trackbacks from: Zithromax For Sale. Zithromax For Sale. Zithromax For Sale. Zithromax For Sale. Zithromax For Sale. Fast shipping Zithromax. Zithromax steet value. Doses Zithromax work. Online buying Zithromax. No prescription Zithromax online.

Tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *