From the course: Unity: Integrating GPS and Points of Interest

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Sort results by nearest first, part 2

Sort results by nearest first, part 2 - Unity Tutorial

From the course: Unity: Integrating GPS and Points of Interest

Sort results by nearest first, part 2

- So the trick is to make this as flexible as possible. Now, you might be wondering why I didn't just put this in right at the beginning and order it by nearest first. Well, maybe you don't want to do that. Maybe you just want to have everything listed and then allow the user to decide. So, by doing it this way, it's kind of giving you the flexibility. Okay, now, what are we going to need next? Well, if we come down here, we're going to need a public void. Well, it doesn't have to be public, even, it can just be a normal void. And this particular one will be called RePopulate. Okay, there we go. Now, RePopulate, this is going to take in a list of items which is the items list, that's passed in. But I'm going to rename this one as itemsPassed, just to make it easier to differentiate. So, what this function will do, then, is it will be passed an organized list of items, depending on what you've decided on, whether that be to order by the title or the distance or any additional variables…

Contents