I try to re create 2nd and third lowest value, but I fail

C20			=	sqrt(((Ref(O, -20) - O)^2) + ((Ref(H, -20) - H)^2) + ((Ref(L, -20) - L)^2) + ((Ref(C, -20) - C)^2) + ((Ref(V, -20) - V)^2) + ((Ref(RSI(14), -20) - RSI(14))^2) + ((Ref(CCI(14), -20) - CCI(14))^2) + ((Ref(StochD(14,3,3), -20) - StochD(14,3,3))^2));
C19			=	sqrt(((Ref(O, -19) - O)^2) + ((Ref(H, -19) - H)^2) + ((Ref(L, -19) - L)^2) + ((Ref(C, -19) - C)^2) + ((Ref(V, -19) - V)^2) + ((Ref(RSI(14), -19) - RSI(14))^2) + ((Ref(CCI(14), -19) - CCI(14))^2) + ((Ref(StochD(14,3,3), -19) - StochD(14,3,3))^2));
C18			=	sqrt(((Ref(O, -18) - O)^2) + ((Ref(H, -18) - H)^2) + ((Ref(L, -18) - L)^2) + ((Ref(C, -18) - C)^2) + ((Ref(V, -18) - V)^2) + ((Ref(RSI(14), -18) - RSI(14))^2) + ((Ref(CCI(14), -18) - CCI(14))^2) + ((Ref(StochD(14,3,3), -18) - StochD(14,3,3))^2));
C17			=	sqrt(((Ref(O, -17) - O)^2) + ((Ref(H, -17) - H)^2) + ((Ref(L, -17) - L)^2) + ((Ref(C, -17) - C)^2) + ((Ref(V, -17) - V)^2) + ((Ref(RSI(14), -17) - RSI(14))^2) + ((Ref(CCI(14), -17) - CCI(14))^2) + ((Ref(StochD(14,3,3), -17) - StochD(14,3,3))^2));
C16			=	sqrt(((Ref(O, -16) - O)^2) + ((Ref(H, -16) - H)^2) + ((Ref(L, -16) - L)^2) + ((Ref(C, -16) - C)^2) + ((Ref(V, -16) - V)^2) + ((Ref(RSI(14), -16) - RSI(14))^2) + ((Ref(CCI(14), -16) - CCI(14))^2) + ((Ref(StochD(14,3,3), -16) - StochD(14,3,3))^2));
C15			=	sqrt(((Ref(O, -15) - O)^2) + ((Ref(H, -15) - H)^2) + ((Ref(L, -15) - L)^2) + ((Ref(C, -15) - C)^2) + ((Ref(V, -15) - V)^2) + ((Ref(RSI(14), -15) - RSI(14))^2) + ((Ref(CCI(14), -15) - CCI(14))^2) + ((Ref(StochD(14,3,3), -15) - StochD(14,3,3))^2));
C15			=	sqrt(((Ref(O, -15) -O)^2)+((Ref(H, -15) -H)^2)+((Ref(L, -15) -L)^2)+((Ref(C, -15) -C)^2)+((Ref(V, -15) -V)^2)+((Ref(RSI(14), -15) -RSI(14))^2)+((Ref(CCI(14), -15) -CCI(14))^2)+((Ref(StochD(14,3,3), -15) -StochD(14,3,3))^2));
C14			=	sqrt(((Ref(O, -14) -O)^2)+((Ref(H, -14) -H)^2)+((Ref(L, -14) -L)^2)+((Ref(C, -14) -C)^2)+((Ref(V, -14) -V)^2)+((Ref(RSI(14), -14) -RSI(14))^2)+((Ref(CCI(14), -14) -CCI(14))^2)+((Ref(StochD(14,3,3), -14) -StochD(14,3,3))^2));
C13			=	sqrt(((Ref(O, -13) -O)^2)+((Ref(H, -13) -H)^2)+((Ref(L, -13) -L)^2)+((Ref(C, -13) -C)^2)+((Ref(V, -13) -V)^2)+((Ref(RSI(14), -13) -RSI(14))^2)+((Ref(CCI(14), -13) -CCI(14))^2)+((Ref(StochD(14,3,3), -13) -StochD(14,3,3))^2));
C12			=	sqrt(((Ref(O, -12) -O)^2)+((Ref(H, -12) -H)^2)+((Ref(L, -12) -L)^2)+((Ref(C, -12) -C)^2)+((Ref(V, -12) -V)^2)+((Ref(RSI(14), -12) -RSI(14))^2)+((Ref(CCI(14), -12) -CCI(14))^2)+((Ref(StochD(14,3,3), -12) -StochD(14,3,3))^2));
C11			=	sqrt(((Ref(O, -11) -O)^2)+((Ref(H, -11) -H)^2)+((Ref(L, -11) -L)^2)+((Ref(C, -11) -C)^2)+((Ref(V, -11) -V)^2)+((Ref(RSI(14), -11) -RSI(14))^2)+((Ref(CCI(14), -11) -CCI(14))^2)+((Ref(StochD(14,3,3), -11) -StochD(14,3,3))^2));
C10			=	sqrt(((Ref(O, -10) -O)^2)+((Ref(H, -10) -H)^2)+((Ref(L, -10) -L)^2)+((Ref(C, -10) -C)^2)+((Ref(V, -10) -V)^2)+((Ref(RSI(14), -10) -RSI(14))^2)+((Ref(CCI(14), -10) -CCI(14))^2)+((Ref(StochD(14,3,3), -10) -StochD(14,3,3))^2));
C9			=	sqrt(((Ref(O, -9) -O)^2)+((Ref(H, -9) -H)^2)+((Ref(L, -9) -L)^2)+((Ref(C, -9) -C)^2)+((Ref(V, -9) -V)^2)+((Ref(RSI(14), -9) -RSI(14))^2)+((Ref(CCI(14), -9) -CCI(14))^2)+((Ref(StochD(14,3,3), -9) -StochD(14,3,3))^2));
C8			=	sqrt(((Ref(O, -8) -O)^2)+((Ref(H, -8) -H)^2)+((Ref(L, -8) -L)^2)+((Ref(C, -8) -C)^2)+((Ref(V, -8) -V)^2)+((Ref(RSI(14), -8) -RSI(14))^2)+((Ref(CCI(14), -8) -CCI(14))^2)+((Ref(StochD(14,3,3), -8) -StochD(14,3,3))^2));
C7			=	sqrt(((Ref(O, -7) -O)^2)+((Ref(H, -7) -H)^2)+((Ref(L, -7) -L)^2)+((Ref(C, -7) -C)^2)+((Ref(V, -7) -V)^2)+((Ref(RSI(14), -7) -RSI(14))^2)+((Ref(CCI(14), -7) -CCI(14))^2)+((Ref(StochD(14,3,3), -7) -StochD(14,3,3))^2));
C6			=	sqrt(((Ref(O, -6) -O)^2)+((Ref(H, -6) -H)^2)+((Ref(L, -6) -L)^2)+((Ref(C, -6) -C)^2)+((Ref(V, -6) -V)^2)+((Ref(RSI(14), -6) -RSI(14))^2)+((Ref(CCI(14), -6) -CCI(14))^2)+((Ref(StochD(14,3,3), -6) -StochD(14,3,3))^2));
C5			=	sqrt(((Ref(O, -5) -O)^2)+((Ref(H, -5) -H)^2)+((Ref(L, -5) -L)^2)+((Ref(C, -5) -C)^2)+((Ref(V, -5) -V)^2)+((Ref(RSI(14), -5) -RSI(14))^2)+((Ref(CCI(14), -5) -CCI(14))^2)+((Ref(StochD(14,3,3), -5) -StochD(14,3,3))^2));
C4			=	sqrt(((Ref(O, -4) -O)^2)+((Ref(H, -4) -H)^2)+((Ref(L, -4) -L)^2)+((Ref(C, -4) -C)^2)+((Ref(V, -4) -V)^2)+((Ref(RSI(14), -4) -RSI(14))^2)+((Ref(CCI(14), -4) -CCI(14))^2)+((Ref(StochD(14,3,3), -4) -StochD(14,3,3))^2));
C3			=	sqrt(((Ref(O, -3) -O)^2)+((Ref(H, -3) -H)^2)+((Ref(L, -3) -L)^2)+((Ref(C, -3) -C)^2)+((Ref(V, -3) -V)^2)+((Ref(RSI(14), -3) -RSI(14))^2)+((Ref(CCI(14), -3) -CCI(14))^2)+((Ref(StochD(14,3,3), -3) -StochD(14,3,3))^2));
C2			=	sqrt(((Ref(O, -2) -O)^2)+((Ref(H, -2) -H)^2)+((Ref(L, -2) -L)^2)+((Ref(C, -2) -C)^2)+((Ref(V, -2) -V)^2)+((Ref(RSI(14), -2) -RSI(14))^2)+((Ref(CCI(14), -2) -CCI(14))^2)+((Ref(StochD(14,3,3), -2) -StochD(14,3,3))^2));
C1			=	sqrt(((Ref(O, -1) -O)^2)+((Ref(H, -1) -H)^2)+((Ref(L, -1) -L)^2)+((Ref(C, -1) -C)^2)+((Ref(V, -1) -V)^2)+((Ref(RSI(14), -1) -RSI(14))^2)+((Ref(CCI(14), -1) -CCI(14))^2)+((Ref(StochD(14,3,3), -1) -StochD(14,3,3))^2));



// Create a matrix and fill it with the custom arrays
mat_source = Matrix(BarCount, 20);
rownum = MxGetSize(mat_source, 0);
colnum = MxGetSize(mat_source, 1);

mat_source = MxSetBlock(mat_source, 0, rownum - 1, 0, 0, C1);
mat_source = MxSetBlock(mat_source, 0, rownum - 1, 1, 1, C2);
mat_source = MxSetBlock(mat_source, 0, rownum - 1, 2, 2, C3);
mat_source = MxSetBlock(mat_source, 0, rownum - 1, 3, 3, C4);
mat_source = MxSetBlock(mat_source, 0, rownum - 1, 4, 4, C5);
mat_source = MxSetBlock(mat_source, 0, rownum - 1, 5, 5, C6);
mat_source = MxSetBlock(mat_source, 0, rownum - 1, 6, 6, C7);
mat_source = MxSetBlock(mat_source, 0, rownum - 1, 7, 7, C8);
mat_source = MxSetBlock(mat_source, 0, rownum - 1, 8, 8, C9);
mat_source = MxSetBlock(mat_source, 0, rownum - 1, 9, 9, C10);
mat_source = MxSetBlock(mat_source, 0, rownum - 1, 10, 10, C11);
mat_source = MxSetBlock(mat_source, 0, rownum - 1, 11, 11, C12);
mat_source = MxSetBlock(mat_source, 0, rownum - 1, 12, 12, C13);
mat_source = MxSetBlock(mat_source, 0, rownum - 1, 13, 13, C14);
mat_source = MxSetBlock(mat_source, 0, rownum - 1, 14, 14, C15);
mat_source = MxSetBlock(mat_source, 0, rownum - 1, 15, 15, C16);
mat_source = MxSetBlock(mat_source, 0, rownum - 1, 16, 16, C17);
mat_source = MxSetBlock(mat_source, 0, rownum - 1, 17, 17, C18);
mat_source = MxSetBlock(mat_source, 0, rownum - 1, 18, 18, C19);
mat_source = MxSetBlock(mat_source, 0, rownum - 1, 19, 19, C20);

// Sort the matrix
mat_sort = MxSort(mat_source, 0);

// Specify the nth values you want to find
nth1 = 2; // 2nd lowest
nth2 = 3; // 3rd lowest
mat_nth = Matrix(rownum, 2);

for (i = 0; i < rownum; i++) {
    nth_lowest1 = mat_sort[i][nth1 - 1];
    nth_lowest2 = mat_sort[i][nth2 - 1];
    mat_nth[i][0] = nth_lowest1;
    mat_nth[i][1] = nth_lowest2;
}

second_lowest_array = MxGetBlock(mat_nth, 0, rownum - 1, 0, 0, True);
third_lowest_array = MxGetBlock(mat_nth, 0, rownum - 1, 1, 1, True);

if (Status("action") == actionExplore)
{    
    Filter = 1;
    AddColumn(CF, "CF", 1.2);
    AddColumn(second_lowest_array, "2nd_Lowest", 1.2);
    AddColumn(third_lowest_array, "3rd_Lowest", 1.2);
    AddColumn(C1, "C1", 1.2);
    AddColumn(C2, "C2", 1.2);
    AddColumn(C3, "C3", 1.2);
    AddColumn(C4, "C4", 1.2);
    AddColumn(C5, "C5", 1.2);
    AddColumn(C6, "C6", 1.2);
    AddColumn(C7, "C7", 1.2);
    AddColumn(C8, "C8", 1.2);
    AddColumn(C9, "C9", 1.2);
    AddColumn(C10, "C10", 1.2);
    AddColumn(C11, "C11", 1.2);
    AddColumn(C12, "C12", 1.2);
    AddColumn(C13, "C13", 1.2);
    AddColumn(C14, "C14", 1.2);
    AddColumn(C15, "C15", 1.2);
    AddColumn(C16, "C16", 1.2);
    AddColumn(C17, "C17", 1.2);
    AddColumn(C18, "C18", 1.2);
    AddColumn(C19, "C19", 1.2);
    AddColumn(C20, "C20", 1.2);
    SetSortColumns(-2);
}

I am sorry, earlier I could not explain properly about my question,
Here is my question, "What am I doing wrong to find the 2nd Lowest and 3rd Lowest among calculated values from C1 upto C20"?
I have attached the exploration picture, which clearly shows that in Row 1 , the 2nd lowest = 11943.63 and 3rd lowest = 15081.08, but the code finds some value which is not even the part of whole series from C1........C20 ?
Please help me rectify my code to find the 2nd and 3rd lowest.
I did refer to earlier post
How to find out the 2nd highest or 2nd lowest value

Later, I figured out what was my mistake, when I re arrange all my arrays from descending to ascending order and run the code, now it shows correct figures.

Thanks !!!