nag_sort_charvec_rank_rearrange (m01ec) is designed to be used typically in conjunction with the M01D ranking functions. After one of the M01D functions has been called to determine a vector of ranks,
nag_sort_charvec_rank_rearrange (m01ec) can be called to rearrange a vector of character data into the rank order. If the vector of ranks has been generated in some other way, then
nag_sort_permute_check (m01zb) should be called to check its validity before
nag_sort_charvec_rank_rearrange (m01ec) is called.
None.
If
or
, elements
m1 to
m2 of
irank do not contain a permutation of the integers
m1 to
m2. On exit, the contents of
ch may be corrupted. To check the validity of
irank without the risk of corrupting
ch, use
nag_sort_permute_check (m01zb).
Not applicable.
This example reads a file of
-character records, each of which contains in characters
to
a name of a NAG function, and in characters
to
an integer frequency. The program first calls
nag_sort_intvec_rank (m01db) to rank the integers in descending order, and then calls
nag_sort_charvec_rank_rearrange (m01ec) to rearrange the names into the order specified by the ranks.
function m01ec_example
fprintf('m01ec example results\n\n');
ch = {'a02aa'; 'a02ab'; 'a02ak'; 'c02al'; 'c02am'; 'c05au'; ...
'c05av'; 'c05aw'; 'c05ax'; 'c05ay'; 'c05az'};
ifreq = [int64(289) 523 531 169 599 1351 ...
240 136 211 183 2181];
m1 = int64(1);
order = 'Descending';
[irank, ifail] = m01db(ifreq, m1, order);
[ch, irank, ifail] = m01ec(ch, m1, irank);
fprintf('Names in order of frequency\n\n');
for i = 1:numel(ch)
fprintf('%s\n',char(ch{i}));
end