qsort

Versión 1.0.0 (2,75 KB) por Bruno Luong
Sort data with user-supplied comparison function
5 descargas
Actualizado 31 mar 2022

Ver licencia

Some examples of usage:
% Sort numerical array in descending order
A=rand(1,100000); tic; [As,is]=qsort(A, @(x,y) y-x); toc
% Sort strings
s = string(randi(200,1,20))
ss = qsort(s, @(x,y) double(x)-double(y))
% Sort structures
s = struct('name',{'smith' 'jackson' 'anna'},'yearofbirth', {40 70 60});
ss = qsort(s, @(x,y) x.yearofbirth-y.yearofbirth);
{ss.name} % returns {'smith'} {'anna'} {'jackson'}
[ss.yearofbirth] % returns 40 60 70
% Sort cell array
c = num2cell(struct('name',{'smith' 'jackson' 'anna'},'yearofbirth', {40 70 60}));
cs = qsort(c, @(x,y) x{1}.yearofbirth-y{1}.yearofbirth);
cs{:}

Citar como

Bruno Luong (2024). qsort (https://www.mathworks.com/matlabcentral/fileexchange/109104-qsort), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2022a
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux
Etiquetas Añadir etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versión Publicado Notas de la versión
1.0.0