This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Using Sort() to reorder a list by date

Simone.C - Friday, December 7, 2012 5:06 AM:

Hi,

I'm trying to use the C# function Sort() to reorder a list of activities that I've created, but I get an error that I could not solve.

The problem is that to use Sort() I need to implement the IComparable interface (or Comparer<T>.Default), that I can't implement.

Has anyone had the some problem?

Do I have to modify the Item class and add the IComparable interface? How should I modify the Item class to implement this interface? I can't find the source file of item class....

This is the code I wrote and the error message:


Innovator myInnovator = this.getInnovator();


//retrieve the activity of open projects

var activity_results = myInnovator.applyMethod("GetActivities", "<string></string>");


//create and populate the list with the results of the query

List<Item> activities = new List<Item>();

for(int i = 0; i < activity_results.getItemCount(); i++)
{
   activities.Add(activity_results.getItemByIndex(i));

}

//sort the activities

activities.Sort()