Check out Modern Chess, our featured variant for January, 2025.


[ Help | Earliest Comments | Latest Comments ]
[ List All Subjects of Discussion | Create New Subject of Discussion ]
[ List Earliest Comments Only For Pages | Games | Rated Pages | Rated Games | Subjects of Discussion ]

Single Comment

Game Courier Developer's Guide. Learn how to design and program Chess variants for Game Courier.[All Comments] [Add Comment or Rating]
H. G. Muller wrote on Sat, Aug 8, 2020 05:23 AM UTC:

I have some problems using sort. I have an array sqrs with 3 squares in it, and want to know what the middle square is. I had expected this could be done by

set sqrs sort #sqrs;
set middle elem 1 #sqrs;

This does not work, however. If I do printr sqrs; before and after the sort, the order of the elements is altered. But the order of the keys (0, 1, 2) is altered too, so that each element is still associated with the same key. And elem apparently retrieves the elements by key, so elem 1 #sqrs is still the same as it was without the sort.

Array
(
    [1] => a1
    [0] => e1
    [2] => h1
)

How can I retreive the e1 from the above array, if I do not know its key, but only that it is the second element?