The current sorting in Telegram for Android is good, except the third part:
Available proxies are at the upper side, and unavailable proxies are at the lower side of the list.
Available proxies are sorted by ping.
Unavailable proxies are sorted by ping, too. (bad)
Unavailable proxies should not be sorted by ping.
Unavailable proxies should be sorted by their previous indexes in the list, and such a sorting actually makes them get ordered by LAT (Last Availability Time).
Therefore, unavailable proxies which have older LAT values (proxies which have not been available in any recent test, and are potentially dead), will go lower in the list after each sort.
Also, healthy unavailable proxies which were available recently, will stay on top of other unavailable proxies.
In a real proxy list (i.e. on the phone of a real proxy user, not the software testers at Telegram company), there are thousands of dead proxies.
Also, each healthy proxy becomes available/unavailable by internet service providers every 30 seconds once, and its availability status becomes switched, frequently.
This is why such a sorting solution is really necessary to distinguish temporary unavailable proxies (healthy proxies) from dead proxies, when removing proxies manually.
*** Important point:
There's no need to save the value of LAT (Last Availability Time) for every proxy on the disk after every ping test.
Because in each sort, previous indexes of proxies can be compared instead of comparing LAT (Last Availability Time) values. Because the previous index plays the role of LAT indirectly (this can be mathematically proven.
Look at the code example in the attached image. It belongs to SharedConfig.java and I have modified the sort method of the official App)
The implementation logic is like this:
Available proxies should be at the upper side, and unavailable proxies should be at the lower side of the list.
Available proxies should be sorted by ping.
In each sort, unavailable proxies should be sorted by the indexes they had in the previous sort (So they'll become sorted by LAT, actually)
Other related suggestions:
The next other possible feature which can be suggested after adding this one, could be, for example, a batch removal button which removes all proxies from the lower half of unavailable proxies (i.e. unavailable proxies which are more likely to be dead), but lets other unavailable proxies remain undeleted. On each click, half of unavailable proxies will be removed.
Also, auto removal could be an option. For example, limiting the list size to 1000 and removing the lowest proxy (i.e. 1001st proxy) every time the user adds a new proxy at the first row of the list.
If you don't add such smart removal features, then users will continue to remove proxies manually, and this is bad because they cannot distinguish dead proxies from healthy unavailable proxies (proxies which are temporarily unavailable for a few seconds, are getting mistakenly deleted by users, every day, because they are not aware of the facts mentioned in the third paragraph)
There are many cards suggesting a batch removal feature for proxies. This card solves their problem too.
Having a large number of dead proxies in the list, causes the proxy auto-switcher to get stuck in checking dead proxies each time it tries finding an available proxy. So, batch removal improves auto-switcher too.
These LAT-based solutions are not 100% precise but they almost solve the problem, and decrease the number of mistaken killed proxies by 99%.