如何在java中对异构列表进行排序?

时间:2017-09-08 04:16:44

标签: java android

在这里,我给出了一个异构的arraylist。我需要在那里排序arraylist到Assenting&分别下降。

Model model;
String[] arr={"A2","4","2","1","A3","3","A1"};

ArrayList<Model> list=new ArrayList<>;
for(int i=0;i<arr.length();i++){
    model=new Model();
    model.setBookNum(arr[i]);
    model.setBookPos(i);
    list.add(model);
} 

这是Model Class

public class Model {
private  String  BookNum="";
private  int BookPos="";

   public String getBookNum() {
       return BookNum;
   }

   public void setBookNum(String bookNum) {
       BookNum = bookNum;
   }

   public String getBookPos() {
       return BookPos;
   }

   public void setBookPos(String bookPos) {
       BookPos = bookPos;
   }
}

并且在同意顺序中的预期结果是1,2,3,4,A1,A2,A3&amp;降序为A3,A2,A1,4,3,2,1。

1 个答案:

答案 0 :(得分:2)

这样做。

ERROR Error: No provider for ChildrenOutletContexts!
    at injectionError (core.es5.js:1169)
    at noProviderError (core.es5.js:1207)
    at ReflectiveInjector_.webpackJsonp.../../../core/@angular/core.es5.js.ReflectiveInjector_._throwOrNull (core.es5.js:2649)
    at ReflectiveInjector_.webpackJsonp.../../../core/@angular/core.es5.js.ReflectiveInjector_._getByKeyDefault (core.es5.js:2688)
    at ReflectiveInjector_.webpackJsonp.../../../core/@angular/core.es5.js.ReflectiveInjector_._getByKey (core.es5.js:2620)
    at ReflectiveInjector_.webpackJsonp.../../../core/@angular/core.es5.js.ReflectiveInjector_.get (core.es5.js:2489)
    at resolveNgModuleDep (core.es5.js:9481)
    at NgModuleRef_.webpackJsonp.../../../core/@angular/core.es5.js.NgModuleRef_.get (core.es5.js:10569)
    at resolveDep (core.es5.js:11072)
    at createClass (core.es5.js:10936)