1

So I have 3 different ArrayList`s which I need to sort to update my RecyclerView.

        final ArrayList<String>  Coin = tinydb.getListString("Coin");
        final ArrayList<Double>  Day = tinydb.getListDouble("Day");
        final ArrayList<Double>  Price = tinydb.getListDouble("Price");

I sort my Price list like this: Collections.sort(Price);

Now I want that my other lists to be in the same order as the already sorterd Price list, because they need to be shown in the same row in my RecylcerView.

Id be glad if someone could help me!

Edit:

I changed my design and now have only one objective Arraylist:

final ArrayList<CoinData> mData = new ArrayList<CoinData>();

My CoinData class :

public class CoinData {

    private static final String TAG = CoinData.class.getSimpleName();

    String symbol = "";
    String cap = "";
    Double price;

    String coinheat = "";
    String url = "";
    Double hour;
    Double day;


    public void setCap(String cap) { this.cap = cap; }
    public void setSymbol(String symbol) { this.symbol = symbol; }
    public void setPrice(Double price) { this.price = price; }
    public void setCoinheat(String coinheat) { this.coinheat = coinheat; }
    public void setUrl(String url) { this.url = url; }
    public void setDay(Double day) { this.day = day; }
    public void setHour(Double hour) { this.hour = hour; }

    public String getCap() { return this.cap; }
    public String getSymbol() { return this.symbol; }
    public Double getPrice() { return this.price; }
    public String getCoinheat() { return this.coinheat; }
    public String getUrl() { return this.url; }
    public Double getHour() { return this.hour; }
    public Double getDay() { return this.day; }

}
  • 14
    That smells like horrible design. Why don't you instead create a custom Object which has those 3 attributes (String coin, Double day and double price) and have a List of this custom object sorted by price? – OH GOD SPIDERS Jan 29 '18 at 15:58
  • Why are they separate in the first place? If you want them together, they should be fields in a same class – Coderino Javarino Jan 29 '18 at 15:58
  • In which way should it be ordered? In crescent way? I suggest you to not use capital letters for begin variable/objects name – Saifer Jan 29 '18 at 15:59
  • Possible duplicate of [Can I sort two lists in relation to each other?](https://stackoverflow.com/questions/10213493/can-i-sort-two-lists-in-relation-to-each-other) – Bernhard Barker Jan 29 '18 at 16:11

0 Answers0