Reverse
This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics. |
Reverse( source )
reverse( source )
Reverse( source )
Reverse( source )
Reverse( source )
Reverse( source )
Description
The Reverse
function returns in reverse order the items in
source
, which can be an Array, a Set, or a Page.
Parameters
Parameter | Type | Definition and Requirements |
---|---|---|
|
Array, Set, or Page |
The array, set, or page whose items should be reversed. |
Returns
When source
is an Array, an Array containing the items
found in source
, with their original order reversed.
When source
is a Set, a Set containing the items found
in source
, with their original order reversed.
When source
is a Page, a Page of the items found in
source
, with their original order reversed.
Examples
-
The following query passes an array to
Reverse
:[ 3, 2, 1, 'c', 'b', 'a' ]
[3, 2, 1, 'c', 'b', 'a']
[3 2 1 c b a]
Arr(LongV(3), LongV(2), LongV(1), StringV(c), StringV(b), StringV(a))
[3, 2, 1, "c", "b", "a"]
[ 3, 2, 1, 'c', 'b', 'a' ]
-
The following query reverses the set of documents in the
Letters
collection (established in the Indexing tutorial, and then paginates the set:{ data: [ Ref(Collection("Letters"), "126"), Ref(Collection("Letters"), "125"), Ref(Collection("Letters"), "124"), Ref(Collection("Letters"), "123"), Ref(Collection("Letters"), "122"), Ref(Collection("Letters"), "121"), Ref(Collection("Letters"), "120"), Ref(Collection("Letters"), "119"), Ref(Collection("Letters"), "118"), Ref(Collection("Letters"), "117"), Ref(Collection("Letters"), "116"), Ref(Collection("Letters"), "115"), Ref(Collection("Letters"), "114"), Ref(Collection("Letters"), "113"), Ref(Collection("Letters"), "112"), Ref(Collection("Letters"), "111"), Ref(Collection("Letters"), "110"), Ref(Collection("Letters"), "109"), Ref(Collection("Letters"), "108"), Ref(Collection("Letters"), "107"), Ref(Collection("Letters"), "106"), Ref(Collection("Letters"), "105"), Ref(Collection("Letters"), "104"), Ref(Collection("Letters"), "103"), Ref(Collection("Letters"), "102"), Ref(Collection("Letters"), "101") ] }
{'data': [Ref(id=126, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=125, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=124, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=123, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=122, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=121, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=120, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=119, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=118, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=117, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=116, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=115, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=114, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=113, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=112, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=111, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=110, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=109, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=108, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=107, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=106, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=105, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=104, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=103, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=102, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=101, collection=Ref(id=Letters, collection=Ref(id=collections)))]}
map[data:[{126 0xc0001321b0 0xc0001321b0 <nil>} {125 0xc000132360 0xc000132360 <nil>} {124 0xc000132510 0xc000132510 <nil>} {123 0xc0001326c0 0xc0001326c0 <nil>} {122 0xc000132870 0xc000132870 <nil>} {121 0xc000132a20 0xc000132a20 <nil>} {120 0xc000132bd0 0xc000132bd0 <nil>} {119 0xc000132d80 0xc000132d80 <nil>} {118 0xc000132f30 0xc000132f30 <nil>} {117 0xc0001330e0 0xc0001330e0 <nil>} {116 0xc000133290 0xc000133290 <nil>} {115 0xc000133440 0xc000133440 <nil>} {114 0xc0001335f0 0xc0001335f0 <nil>} {113 0xc0001337a0 0xc0001337a0 <nil>} {112 0xc000133950 0xc000133950 <nil>} {111 0xc000133b00 0xc000133b00 <nil>} {110 0xc000133cb0 0xc000133cb0 <nil>} {109 0xc000133e60 0xc000133e60 <nil>} {108 0xc000154030 0xc000154030 <nil>} {107 0xc00016c0c0 0xc00016c0c0 <nil>} {106 0xc00016c270 0xc00016c270 <nil>} {105 0xc00016c420 0xc00016c420 <nil>} {104 0xc00016c5d0 0xc00016c5d0 <nil>} {103 0xc00016c780 0xc00016c780 <nil>} {102 0xc00016c930 0xc00016c930 <nil>} {101 0xc00016cae0 0xc00016cae0 <nil>}]]
ObjectV(data: Arr(RefV(id = "126", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "125", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "124", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "123", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "122", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "121", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "120", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "119", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "118", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "117", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "116", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "115", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "114", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "113", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "112", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "111", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "110", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "109", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "108", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "107", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "106", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "105", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "104", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "103", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "102", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "101", collection = RefV(id = "Letters", collection = RefV(id = "collections")))))
{data: [ref(id = "126", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "125", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "124", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "123", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "122", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "121", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "120", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "119", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "118", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "117", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "116", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "115", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "114", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "113", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "112", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "111", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "110", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "109", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "108", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "107", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "106", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "105", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "104", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "103", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "102", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "101", collection = ref(id = "Letters", collection = ref(id = "collections")))]}
{ data: [ Ref(Collection("Letters"), "126"), Ref(Collection("Letters"), "125"), Ref(Collection("Letters"), "124"), Ref(Collection("Letters"), "123"), Ref(Collection("Letters"), "122"), Ref(Collection("Letters"), "121"), Ref(Collection("Letters"), "120"), Ref(Collection("Letters"), "119"), Ref(Collection("Letters"), "118"), Ref(Collection("Letters"), "117"), Ref(Collection("Letters"), "116"), Ref(Collection("Letters"), "115"), Ref(Collection("Letters"), "114"), Ref(Collection("Letters"), "113"), Ref(Collection("Letters"), "112"), Ref(Collection("Letters"), "111"), Ref(Collection("Letters"), "110"), Ref(Collection("Letters"), "109"), Ref(Collection("Letters"), "108"), Ref(Collection("Letters"), "107"), Ref(Collection("Letters"), "106"), Ref(Collection("Letters"), "105"), Ref(Collection("Letters"), "104"), Ref(Collection("Letters"), "103"), Ref(Collection("Letters"), "102"), Ref(Collection("Letters"), "101") ] }
-
The following query reverses the page of results from paginating the documents in the
Letters
collection:{ before: [ Ref(Collection("Letters"), "104") ], after: [ Ref(Collection("Letters"), "107") ], data: [ Ref(Collection("Letters"), "106"), Ref(Collection("Letters"), "105"), Ref(Collection("Letters"), "104") ] }
{'before': [Ref(id=104, collection=Ref(id=Letters, collection=Ref(id=collections)))], 'after': [Ref(id=107, collection=Ref(id=Letters, collection=Ref(id=collections)))], 'data': [Ref(id=106, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=105, collection=Ref(id=Letters, collection=Ref(id=collections))), Ref(id=104, collection=Ref(id=Letters, collection=Ref(id=collections)))]}
map[after:[{107 0xc00016e360 0xc00016e360 <nil>}] before:[{104 0xc00016e1b0 0xc00016e1b0 <nil>}] data:[{106 0xc00016e510 0xc00016e510 <nil>} {105 0xc00016e6c0 0xc00016e6c0 <nil>} {104 0xc0001480f0 0xc0001480f0 <nil>}]]
ObjectV(before: Arr(RefV(id = "104", collection = RefV(id = "Letters", collection = RefV(id = "collections")))),after: Arr(RefV(id = "107", collection = RefV(id = "Letters", collection = RefV(id = "collections")))),data: Arr(RefV(id = "106", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "105", collection = RefV(id = "Letters", collection = RefV(id = "collections"))), RefV(id = "104", collection = RefV(id = "Letters", collection = RefV(id = "collections")))))
{before: [ref(id = "104", collection = ref(id = "Letters", collection = ref(id = "collections")))], after: [ref(id = "107", collection = ref(id = "Letters", collection = ref(id = "collections")))], data: [ref(id = "106", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "105", collection = ref(id = "Letters", collection = ref(id = "collections"))), ref(id = "104", collection = ref(id = "Letters", collection = ref(id = "collections")))]}
{ before: [ Ref(Collection("Letters"), "104") ], after: [ Ref(Collection("Letters"), "107") ], data: [ Ref(Collection("Letters"), "106"), Ref(Collection("Letters"), "105"), Ref(Collection("Letters"), "104") ] }
Notice that
Reverse
has reversed the order of the results in the page, but has not affected the pagination order.