Ordenação de Arrays com Java

A ordenação básica de um Array, sem nenhum método específico..

package arrays;

public class OrdenacaoArrays {

	public void ordenaArrayFormaComum(int [] array) {
		int aux = 0;
		for (int i = 0; i < array.length - 1; i++) {
			for (int j = i + 1; j < array.length; j++) {
				if(array[i] > array[j]) {
					aux = array[i];
					array[i] = array[j];
					array[j] = aux;
				}
			}
		}

		System.out.print("\nArrays ordenados: ");
		for(int i = 0; i < array.length; i ++) {
			System.out.print(array[i] + " ");
		}
	}

}
Ordenação de Arrays com Java

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s