Selection Sort-array sorting
<p>When I run it only the first smallest number gets sorted. Is the problem somewhere in the loops?</p>

<pre><code>def selectionSort(A):
    n=len(A)
    print(n)

    mini=0
    for i in range(0,n-2):
        mini=i
        for j in range(i+1,n-1):
            if A[j]&lt;A[mini]:
                mini=j
            if i!=mini:
                temp=A[i]
                A[i]=A[mini]
                A[mini]=temp

    return A
</code></pre>

<p>There are actually two issues:</p>

<ol>
<li>Your second <code>if</code> should be outside the inner <code>for</code> loop.</li>
<li>And your outer and inner loop should be iterating till <code>n-1</code> and <code>n</code> respectively, instead of <code>n-2</code> and <code>n-1</code>.</li>
</ol>

<hr>

<p>Hence, your code should be like:</p>

<pre><code>def selectionSort(A):
    n=len(A)
    print(n)
    mini=0
    for i in range(0,n-1):
        mini=i
        for j in range(i+1,n):
            if A[j]&lt;A[mini]:
                mini=j
        if i!=mini:
            temp=A[i]
            A[i]=A[mini]
            A[mini]=temp
    return A
</code></pre>

<p>Output:</p>

<pre><code>&gt;&gt;&gt; selectionSort([2, 5, 7, 1, 3, 0, 10, 43, 21, 32])
10
[0, 1, 2, 3, 5, 7, 10, 21, 32, 43]
</code></pre>

<p><em>Suggestion:</em> You do not need temp variable in python for swapping values. You can simply do it as:</p>

<pre><code>&gt;&gt;&gt; a = 5
&gt;&gt;&gt; b = 3
&gt;&gt;&gt; a, b = b, a
&gt;&gt;&gt; a
3
&gt;&gt;&gt; b
5
</code></pre>

<p>In your swapping code, it would be as: <code>A[i], A[mini] = A[mini], A[i]</code></p>

python