Order Drivers by positions gained

Posts: 38
Nick,

I am trying to generate a ticker based on positions gained. I dont see that as a selection. Is there a way to work around this with a data set?

Thanks,
Harold
Posts: 785
You can easily achieve this with a custom dataset script. These are only available on Beta and Alpha channel at the moment unfortunately but I plan to merge them to stable soon.

Just add a new Script, and in the dialog select the template as "Custom dataset script". The script will get some complicated looking code, but all you need to do is put your own stuff in the "OrderResults" function. That one allows you to sort the results as you want, and after saving and compiling the script you should be able to select it as a dataset.

In your case you'd probably end up with this:
using System;
using System.Linq;
using System.Collections.Generic;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemeEditor.ThemeModels.DataSets;
using ATVO.ThemesSDK.Data.Results;
using ATVO.ThemesSDK.Ordering;

namespace Scripts
{
public class PosGainedDataset : CustomStandingsDataSet
{
protected override IList<IEntitySessionResult> FilterResults(
ISimulation sim,
IList<IEntitySessionResult> results)
{
return results;
}

protected override IList<IEntitySessionResult> OrderResults(
ISimulation sim,
IList<IEntitySessionResult> results,
IDataOrder order)
{
return results.OrderByDescending(r => r.LivePosition - r.StartPosition).ToList();
}

protected override ISessionResult GetSession(ISimulation sim)
{
return sim.Session.Current;
}
}
}


There is no 'positions gained' property, but you can easily calculate it just by taking current (optionally: live) position and subtracting their starting position.
Posts: 38
Nick,

Thanks. I will implement this.

Thanks
Posts: 287
Just to inverse the calcul to get in good place ;)
return results.OrderByDescending(r => r.StartPosition - r.LivePosition ).ToList();