Hey @Anonymous
Glad to explain:
The TL;DR - even when Sorted backwards, it loads let's say 25 entries, then we use First() to pull the first of those 25 entries.
So think about when you you are actually navigating a sharepoint list - as you're scrolling down it effectively loads the next X values once you reach the bottom, and then keeps doing that as you go along, so it's effectively only loading a small subset initially and then paging in new data X records at a time.
Now when we use Sort, that's a basic delegable function - the data source knows how to sort backwards and forwards and will do that for us before delegation is even an issue, especially considering what I said above, it will load that data in sections, from back to front as we've applied a Sort - this means that it only has to load X number of values (whatever it's limit is, can't remember the sharepoint default number of items cache) before it caches the next set of records in, and this then makes the first X values effectively {(LastID), (LastID - 1), (LastID - 2), (LastID - 3)... }
So we're still in delegable territory, and now we use the First() function, which pulls just one record (the first record within the currently-applied sorting and filtering), then we are able to access any of the properties by using .property IE .ID
In terms of your question around ClearCollect - think of a library.
Side-Note: I'm not particularly fond of doing ClearCollect within PowerApps, as I don't think it's a very efficient solution, and once you move to mobile-use then you want to keep the number of records pulled to an absolute minimum for performance reasons when pulling data over mobile connection - usually there is a better, more delegable way.
..back to the library:
So you want to find the last book in the library? Ok, so the librarian asks you to Clear out the shelves and Collect every single book in the library and load it into your truck, then they ask you to go through and check the ISBN number and look that up against a dewey-decimal ID number of every book until you find the one with the Maximum value.
You then tell them exactly where to shove it because surely they should have some sort of a Dewey-decimal system where books are Sorted before someone goes looking for one.
The librarian then says "Oh my, yes we do have that system but you never asked for that, if you start at that end of the library you'll find the Last items and we've divided it into smaller sections within shelves where you'll find the last 25 items per shelf."
..and that, is why I don't use ClearCollect unless absolutely necessary - it's bulky, it's unnecessary data unless you absolutely need local access to items, it increases loading times on mobile devices causing user frustrations, it doesn't scale, and your code has to assume how big your database will get as it can only collect 2000 items per collection currently (so if you have a DB with 6 thousand items, and you plan for 20k, but that gets reached within a month, then you have to re-write your code to collect those additional items and plan ahead for further expansions and it's just not scalable that way as you'll always end up writing for more expansions)
Ok, enough rambling, hopefully I've managed to explain a bit around why we are able to do this 🙂
Cheers,
ManCat