Advertisement
xXx_Fortis_xXx

Untitled

Jun 17th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.33 KB | None | 0 0
  1. function [ARR, IND] = mSort (array)
  2.     len = length(array);
  3.     ind = [1:len];
  4.     for j = [1:len - 1]
  5.         for i = [1:len - j]
  6.             if (array(i) > array(i + 1))
  7.                 t = array(i);
  8.                 array(i) = array(i + 1);
  9.                 array(i + 1) = t;
  10.                 t = ind(i);
  11.                 ind(i) = ind(i + 1);
  12.                 ind(i + 1) = t;
  13.             end
  14.         end
  15.     end
  16.     ARR = array;
  17.     IND = ind;
  18. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement