【问题标题】:Order linq.js results numerically以数字方式订购 linq.js 结果
【发布时间】:2015-05-26 08:26:01
【问题描述】:

我正在尝试在资源规划工具中返回一个周期(周)列表。目前我正在返回数据和排序,但 linq.js 按字母顺序排序并返回 1、11、12、3、...

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

var teamMembers = Enumerable
    .From(data)
    .SelectMany("$.persons")
    .SelectMany("$.periods")
    .Where("$.teamName == '" + teamName + "'")
    .OrderBy("$.periodName")

【问题讨论】:

    标签: javascript linq.js


    【解决方案1】:

    这样试试

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

    【讨论】:

      【解决方案2】:
      var teamMembers = Enumerable
          .From(data)
          .SelectMany("$.persons")
          .SelectMany("$.periods")
          .Where("$.teamName == '" + teamName + "'")
          .OrderBy(function (x) { return x.periodName; })
      

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-06-02
        • 2013-03-06
        • 1970-01-01
        • 2015-05-30
        • 2016-06-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多