B4J Question list sorttype

tufanv

Expert
Licensed User
Longtime User
Hello,

I have a list like this when i log the list:

B4X:
log:(ArrayList) [{VOLUME24HOUR=525213.4413355798, MARKET=BitTrex, LASTTRADEID=33271928, PRICE=0.00061532, OPEN24HOUR=0.000667, LOW24HOUR=0.00061, TOSYMBOL=BTC, LASTVOLUME=3.29, FROMSYMBOL=WAVES, LASTVOLUMETO=0.0020244, LASTUPDATE=1511259602, HIGH24HOUR=0.00067482, VOLUME24HOURTO=334.28117143, FLAGS=4, TYPE=2}, {VOLUME24HOUR=0, MARKET=Cryptopia, LASTTRADEID=1504246706, PRICE=0.0012501, OPEN24HOUR=0.0012501, LOW24HOUR=0.0012501, TOSYMBOL=BTC, LASTVOLUME=6, FROMSYMBOL=WAVES, LASTVOLUMETO=0.0075006, LASTUPDATE=1504246706, HIGH24HOUR=0.0012501, VOLUME24HOURTO=0, FLAGS=2, TYPE=2}, {VOLUME24HOUR=2842.37924685, MARKET=LiveCoin, LASTTRADEID=208282494, PRICE=0.00063356, OPEN24HOUR=0.0006699, LOW24HOUR=0.0006253, TOSYMBOL=BTC, LASTVOLUME=11.05, FROMSYMBOL=WAVES, LASTVOLUMETO=0.0070008380000000005, LASTUPDATE=1511253228, HIGH24HOUR=0.00066992, VOLUME24HOURTO=1.8199635423277862, FLAGS=2, TYPE=2}, {VOLUME24HOUR=24326.05102541, MARKET=Liqui, LASTTRADEID=40799827, PRICE=0.0006232, OPEN24HOUR=0.0006592...

As I can see there is a VOLUME24HOUR in the fields but when i use
Exchanges.SortType("VOLUME24HOUR",False)

it says :
java.lang.NoSuchFieldException: VOLUME24HOUR

What Am I doing wrong here ?
Thanks
 

DonManfred

Expert
Licensed User
Longtime User
what is the output of the log of one entry? Is it a STRING or is it a TYPE?
How are you reading/filling the list.
Give us more info
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
What is the type of each element in this list? It looks like a Map.
what is the output of the log of one entry? Is it a STRING or is it a TYPE?
How are you reading/filling the list.
Give us more info
This is how the data filled :
B4X:
Dim root2 As Map = parser.Nextobject

            Dim Data As Map = root2.Get("Data")

            Dim Exchanges As List = Data.Get("Exchanges")

it is a result of http job after parsing the json
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
And WHERE IS YOUR CUSTOM TYPE in this code which you add to the LIST?`
I´m out here.... :mad:

List.Sorttype does not work with Maps or List (inside the List). In ONLY works with custom types...

B4X:
Type mytype(id As Int, Name As String, time As Lon)


dim l as list
l.initialize
dim myt as mytype
myt.initialize
myt.id = 1
myt.name = "myname"
myt.time = 12345678

l.add(myt)

l.sorttype("time", false)
or
l.sorttype("name", false)
or
l.sorttype("id", false)
 
Last edited:
Upvote 0

tufanv

Expert
Licensed User
Longtime User
And WHERE IS YOUR CUSTOM TYPE in this code which you add to the LIST?`
I´m out here.... :mad:

List.Sorttype does not work with Maps or List (inside the List). In ONLY works with custom types...

B4X:
Type mytype(id As Int, Name As String, time As Lon)


dim l as list
l.initialize
dim myt as mytype
myt.initialize
myt.id = 1
myt.name = "myname"
myt.time = 12345678

l.add(myt)

l.sorttype("time", false)
or
l.sorttype("name", false)
or
l.sorttype("id", false)

I tought that they were fields that can be used to sort. I understand that i have to create them my own.
Thanks
 
Upvote 0
Top