N
N
Nikolay Matyushkin2018-08-03 15:42:28
1C-Bitrix
Nikolay Matyushkin, 2018-08-03 15:42:28

How, when getting a list of users, sort them by user field?

Hello. There is a code where I get a complete list of users with their custom fields. I need to sort users by a custom field called UF_RAITING, how can I do this if the first parameter is add. does not accept fields?

$filter = array();
$arParams["SELECT"] = array( "UF_*" );
$rsUsers = CUser::GetList(($by="ID"), ($order="asc"), $filter, array("SELECT"=>array("UF_*")));

while ($arUser = $rsUsers->Fetch()):
   print_r($arUser);
endwhile;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gerasimov, 2018-08-04
@Devilz_1

Everything is written in the documentation:
An array for sorting, having the form by1=>order1[, by2=>order2 [, ..]], where by1, ... - sort field, can take the following values:
id - group code;
section - parent group code;
name - group name;
code - character group code;
active - group activity;
left_margin - left margin;
depth_level - nesting depth (starts from 1);
sort - sort index;
created - by group creation time;
created_by - by group creator ID;
modified_by - by the ID of the user who changed the group;
element_cnt - number of elements in the group, works only if bIncCnt = true;
timestamp_x - last modified time.
order1, ... - sort order, can take the following values:
asc - ascending;
desc - descending.
The default value Array("SORT"=>"ASC") means that the selection result will be sorted in ascending order. If you set an empty array Array(), then the result will not be sorted

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question