On Fri, Jun 2, 2017 at 11:25 AM, Max Vlasov <max.vlasov@gmail.com> wrote:
The docs say backlinks are sorted by titles (https://www.mediawiki.org/wiki/API:Backlinks .... "Ordered by linking page title").

That's not correct. Fixed the doc.

They're actually ordered by linking pageid if you don't specify multiple values for blnamespace, or by namespace then pageid if you do.

It may be better to use prop=linkshere rather than list=backlinks. That module is much less complicated and hacky.
 
So is it possible to implement other kind of sort, for example, something like PageRank for backlinks, so the links are sorted by the number of links coming to them?

No. The database structure doesn't allow efficient querying with any ordering other than the ordering used here. Number of incoming links in particular would be extremely slow, or with some rather significant changes to the code and database it might be able to be improved to merely being very slow.

BTW, Google's "PageRank" is, as far as I know, more complicated than just "number of incoming links".


--
Brad Jorsch (Anomie)
Senior Software Engineer
Wikimedia Foundation