The ReindexPhotoSet method changes the order of photos in a gallery or collection.
void ReindexPhotoSet( long photoSetId, int startIndex, int mapping )
The mapping array describes the new indexing of the photoset: the index in the array plus startIndex value is the new photo index; the value is the original photo index. For example, assume that the photoset with id=100 has 5 photos. For this photoset:
// reverses the order of photos in the photoset ReindexPhotoSet(100, 0, [4, 3, 2, 1, 0]) // swaps the first two photos ReindexPhotoSet(100, 0, [1, 0, 2, 3, 4]) // moves the last photo to the first position and shifts the remaining // photos towards the end ReindexPhotoSet(100, 0, [4, 0, 1, 2, 3])
The mapping array does not have to list all the photos in the photoset, but it has to be a complete description of all the changes. For example, the following call is incorrect:
// returns an error ReindexPhotoSet(100, 0, [4, 0, 1, 2])
Even though it is "obvious" that photo #3 should be the last as there is no other place for it, the method cannot infer it.
The startIndex parameter is useful when there is a small area of changes localized in a middle of a photoset. For example, to swap photos #43 and #44 in a gallery with many photos, the following call is enough:
// swap photos #43 and #44 ReindexPhotoSet(101, 43, [44, 43])
The photoset identified by the photoSetId parameter must be owned by the currently authenticated user.