Sergio Crespo Toubes
07/10/2018, 10:55 AMproducts.sort {
a,b -> }
Andreas Sinz
07/10/2018, 10:57 AMSergio Crespo Toubes
07/10/2018, 10:59 AMSergio Crespo Toubes
07/10/2018, 10:59 AMgildor
07/10/2018, 11:00 AMgildor
07/10/2018, 11:01 AMgildor
07/10/2018, 11:02 AMproducts.sortWith(Comparator { a, b -> })
Sergio Crespo Toubes
07/10/2018, 11:03 AMgildor
07/10/2018, 11:03 AMproducts.sortBy { it.distance }
or
products.sortBy { it.location }
gildor
07/10/2018, 11:04 AMSergio Crespo Toubes
07/10/2018, 11:04 AMval productLocation = Location()
productLocation.latitude = it.address!!.latitude
productLocation.longitude = it.address!!.longitude
mLocationManager.distanceTo(productLocation, androidLocation)
Sergio Crespo Toubes
07/10/2018, 11:04 AMSergio Crespo Toubes
07/10/2018, 11:04 AMSergio Crespo Toubes
07/10/2018, 11:04 AMgildor
07/10/2018, 11:05 AMmap
and than sort just by distance.
Because calculating distnace on each comparasion doesn’t looks like an efficient way to do that (you have much more comparisons than items in your list)