I have a file called Item.csv file which has the following information:
categoryName, currentPrice, currencyId
Boots, 19.95, GBP
Thermometers,2.03,GBP
Garden Sheds,38.95,GBP
I want to sort the content by price by making use of QSortAlgorithm and save it as sortedItem.csv. So far I can pull out the price column and sort it by making use of QSortAlgorithm but I don't know how to put it all together. Any help would be highly appreciated.
List <double> priceList=new List<double>();
using (StreamReader sr = new StreamReader("Items.csv"))
{
String line;
while ((line = sr.ReadLine()) != null)
{
string[] parts = line.Split(',');
string price = parts[1];
if(price!="currentPrice")
priceList.Add(Convert.ToDouble(price));
}
}
double [] priceArray=new double[priceList.Count];
priceArray=priceList.ToArray();
QuickSort(ref priceArray);
for(int i=0;i<priceArray.Length;i++)
Console.WriteLine(priceArray[i]);