Time for action – let's create a custom class for live sorting

Follow the given steps:

  1. Create a class library project. Call it LiveSortedListAPI.
  2. Change the name of the class from Class1.cs to LiveSortedList.cs.
  3. Change the header of the class as follows:
    public class LiveSortedList<T>  where T:IComparable
  4. Add the following private variables and properties:
    LinkedList<T> innerDS;
    LinkedList<T> innerDSDesc;
    LinkedList<T> actualValues;
    
    public List<T> LiveSortedValues
    {
      get
      {
        return new List<T>(innerDS);
      }
    }
    public List<T> LiveSortedValuesDesc
    {
      get
      {
        return new List<T>(innerDSDesc);
      }
    }
    
    public List<T> ActualValues
    {
      get
      {              
        return new List<T>(actualValues);
      }
    }
  5. Add the constructor as follows:
    public LiveSortedList() { innerDS = new LinkedList<T>(); innerDSDesc ...

Get .NET 4.0 Generics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.