Order linq.js 结果数值

Order linq.js results numerically

我正在尝试 return 资源规划工具中的周期(周)列表。目前我正在 return 处理数据和排序,但是 linq.js 按字母顺序排序并且 returns 1, 11, 12, 3, ...

如何修改查询以便按数字排序? 1, 2, 3 ...

var teamMembers = Enumerable
    .From(data)
    .SelectMany("$.persons")
    .SelectMany("$.periods")
    .Where("$.teamName == '" + teamName + "'")
    .OrderBy("$.periodName")
var teamMembers = Enumerable
    .From(data)
    .SelectMany("$.persons")
    .SelectMany("$.periods")
    .Where("$.teamName == '" + teamName + "'")
    .OrderBy(function (x) { return x.periodName; })

您必须确保您订购的是一个号码。

这样试试

var teamMembers = Enumerable
    .From(data)
    .SelectMany("$.persons")
    .SelectMany("$.periods")
    .Where("$.teamName == '" + teamName + "'")
    .OrderBy(function (x) { return parseInt(x.periodName); })