React Native - FlatList ordering without sorting data

狂风中的少年 提交于 2019-12-02 08:18:52

Basically you are saying, I want Pizzar, but do not use sausage, meat, whatever. The answer is therefore No.

In order to perform efficient sorting and ordering, you can try linq.js

linq.js, in short is LINQ for JavaScript. Some particular useful/pertinent features include:

  • implement all .NET 4.0 methods and many extra methods (inspiration from Rx, Achiral, Haskell, Ruby, etc...)
  • complete lazy evaluation
  • binding for Reactive Extensions for JavaScript(RxJS) and IntelliSense

If Linq.JS can solve your performance issue, you should sort it first and then render the sorted data source.

Another option is to use lodash, whose performance is claimed to be even better, see this link for details.

Here are the code snippets to sort some data: LINQ.JS:

var queryResult = $.Enumerable.From(jsonArray)
  .OrderBy(function(x) {
    return x.user.screen_name
  })
  .Select(function(x) {
    return x.user.screen_name + ':' + x.text
  })
  .ToArray();

Lodash:

var queryResults = _.chain(jsonArray)
.sortBy(function (x) { return x.user.screen_name })
.map(function(x) {
    return x.user.screen_name + ':' + x.text
  })
.value();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!