Untitled
unknown
plain_text
a year ago
643 B
38
Indexable
type BacktestResult
float winrate
float pnl
method getByString(BacktestResult this, string sortValue) =>
switch sortValue
"WINRATE" => this.winrate
"PNL" => this.pnl
=> this.winrate // Varsayılan
method sortBy(array<BacktestResult> this, string sortValue, bool isDescending) =>
m = matrix.new<float>(this.size(), 2)
for [i, t] in this
m.set(i, 0, float(i))
m.set(i, 1, t.getByString(sortValue))
m.sort(1, isDescending ? order.descending : order.ascending)
result = array.new<BacktestResult>()
for i in m.col(0)
result.push(this.get(int(i)))
result
Editor is loading...
Leave a Comment