Sort Data Example (C#)
[C#]
/* COPYRIGHT(C), SIMPLEXAR SOFTWARE LIMITED, 2006-2008.
* All rights reserved.
*
* Use of this copyright notice is precautionary only, and does not imply
* publication or disclosure. The content of this work contains confidential
* and proprietary information of Simplexar Software Limited. Any duplication,
* modification, distribution, or disclosure in any form, in whole, or in part,
* is strictly prohibited without express prior written permission.
*/
// Get namespaces.
using System;
using Simplexar.Statsar;
// Start namespace.
namespace Simplexar.Examples.Statsar
{
/// <summary>
/// This example uses the DataSheet.Sort method to sort a data sheet.
/// Data is sorting according to multiple columns in both ascending
/// and descending orders.
/// </summary>
public static class Example
{
/// <summary>
/// The application entry point.
/// </summary>
public static void Main()
{
try
{
RunExample();
}
catch(Exception exception)
{
Console.WriteLine(exception);
}
Console.WriteLine("Press ENTER to terminate.");
Console.ReadLine();
}
private static void RunExample()
{
// Create a calculator.
StatsCalculator calculator = new StatsCalculator();
// Use the calculator to load the sheet.
DataSheet sheet = calculator.Load(
@"..\..\..\..\..\Data\ExamResults.csv");
Console.WriteLine(sheet);
// Sort by first name.
sheet.Sort("FirstName");
Console.WriteLine(sheet);
// Sort by age descending then by english result ascending.
sheet.Sort(
new string[]{ "Age", "EnglishResult" },
new SortOrder[]{ SortOrder.Descending, SortOrder.Ascending });
Console.WriteLine(sheet);
}
}
}