Here's the general premises of a selection sort algorithm: Take a list, then find the minimum. Put that value at the beginning of the list. Then, take the rest of the list and repeat those steps (of course, you don't put them at the beginning of the whole list, just the beginning of the partial list).

You're getting all 2's after because your swap algorithm isn't actually swapping the values. Here's what it's doing:

say number[x] = 5 and number[a] = 3

temp = number[x]; // temp = 5
number[x] = number[a]; // number[x] = 3
number[a] = number[x]; // number[a] = 3

What that last line really should be is number[a] = temp;

This will still cause problems though, because values are getting swapped for no reason what-so ever. What you really should have inside is a find minimum algorithm, then in your outer for loop perform the appropriate swap:

for (int x = 0; x < number.length; i++)
{
int minIndex = x;
for (int a = x; a < number.length; a++)
{
if(number[minIndex] > number[a])
{
// found a smaller value in the remaining list
minIndex = a;
}
}
// minIndex now has the index of the smallest number in the remaining list
int temp = number[minIndex];
number[minIndex] = number[x];
number[x] = temp;
}