anchor.diff:                          end, UsersIDs),
                       #user_state{privileges = CurrentPrivileges} = CurrentUser = lists:keyfind(GRUID, 2, UserStates),
                       UserStatesWithoutCurrent = lists:keydelete(GRUID, 2, UserStates),
  -                    UserStatesSorted = [CurrentUser | lists:keysort(3, UserStatesWithoutCurrent)],
  +                    UserStatesSorted = [CurrentUser | sort_states(UserStatesWithoutCurrent)],
   
                       % Synchronize spaces data (belonging to certain group)
                       {ok, SpacesIDs} = gr_groups:get_spaces({user, AccessToken}, GroupID),
  
positive.code:                             #space_state{id = SpaceID, name = SpaceName}
  
                          end, SpacesIDs),
                      SpaceStatesSorted = lists:keysort(3, SpaceStates),
                      #group_state{id = GroupID, name = GroupName, users = UserStatesSorted, spaces = SpaceStatesSorted, current_privileges = CurrentPrivileges};
                  _ ->
                      % User does not have rights to view this group
  
negative.code:         end, GroupStates),
      SortedGroupStates = CanView ++ CannotView,
      #page_state{groups = SortedGroupStates, gruid = GRUID, access_token = AccessToken, expanded_groups = ExpandedGroups}.
  
  
  sort_states(TupleList) ->
      ListToSort = lists:map(
          fun(T) ->
              {string:to_lower(gui_str:binary_to_unicode_list(element(3, T))), element(2, T)}
          end, TupleList),
      lists:map(
          fun({_, StateID}) ->
              lists:keyfind(StateID, 2, TupleList)
          end, lists:sort(ListToSort)).
  
  
  %% event/1
  