I need to write a code where it takes 6 distance inputs and orders them based on their proximity.

Basically, I need to write a code where lets say, there is 3 enemies, and in the unity console bar, it should appear ordering them based on their proximity.

For example:
Enemy1 is closer to you.

Take the Vector.Distance() between each enemy and the player, then order them in a list or array from smallest distance to largest.

With only two enemies, you can use one if with prints. With 3+, you have to take it seriously. For serious, you separate things out. Step one is to get them sorted. Then you can easily do whatever else (print to console, find closest, … )

Standard sorting says to first put all the items in an array. For the array, you don’t just want to know “the closest is 4.6 away.” You probably want to know “Orc Steve is closest, which is 4.6.” So, it makes sense to put the whole enemy in the array, not just the location. A whole enemy is the Transform (or the gameObject, but alucarj already showed you a nice Transform sorter.)

So, put all the enemies, in any order, into an array of Transforms. Then run the sort. A good thing about sorting arrays is everyone does it, not just Unity. So, you can just search for “C# array sort”.

With only three, you could sort by hand, but still: sort first, then use. A 3-sort with ifs look like:

Transform Ca, Cb, Cc: // closest in order
Transform E1, E2, E3; // pretend these are the enemies, unsorted
float d1, d2, d3; // distance to each enemy
d1 = Vector3.magnitude(transform.position - E1.position), // same for E2 and E3

if(d1<d2 && d1<d3) {
  Ca=E1;
  if(d2<d3) { Cb=E2; Cc=E3;}
  else { Cb=E3; Cc=E2; }
}
else { // E1 is not the closest
  if(d2<d3) {
    Ca=E2;
    if(d1<d3) { Cb=E1; Cc=E3; }
    else { Cb=E3; Cc=E2; }
  }
  else { // E3 is closest
    Ca=E3;
    if(d1<d2) { Cb=E1; Cc=E3; }
    else { Cb=E2; Cc=E1; }
  }
}

That’s pretty ugly (and easy to get a single variable wrong.) A 4-sort is four times as long, which is why its easier to just learn arrays and sort that way.

OK, so this script actually does what you want. It is built so you can change the size of your enemies distance array to whatever size you like. The enemies distance array is hard-coded in the start, but as I say in the comments, you can use the Inspector to declare the size of your enemies distance array, and then fill in the values for the distances. The distances can be floats. If you use the inspector, comment out where the enemies array is sized and populated (I have put //==== at the beginning and end of this section) :

#pragma strict

public var enemies : float[]; // enemies in order [0, 1, 2, 3, 4, 5]
private var enemy : int[]; // reference to the position of the enemy

function Start()
{
	// all this can be assigned in the Inspector
	// set the size of the enemies array, then add the distances
	
	// =====================
	enemies = new float[6];
	
	enemies[0] = 3.1;
	enemies[1] = 5.2;
	enemies[2] = 2.3;
	enemies[3] = 7.4;
	enemies[4] = 9.5;
	enemies[5] = 4.6;
	// =====================
	
	// ----
	
	// store enemy position from enemies array
	enemy = new int[enemies.Length];
	
	for ( var e : int = 0; e < enemy.Length; e ++ )
	{
		enemy[e] = e;
	}
	
	// ----
	
	SortEnemiesByDistance();
	
	DebugEnemyDistances();
}

function SortEnemiesByDistance()
{
	// bubble-sort distances
	for ( var e : int = 0; e < enemies.Length - 1; e ++ )
	{
		if ( enemies[e + 0] > enemies[e + 1] )
		{
			// sort distances
			var tempStoreDistance : float = enemies[e];
			enemies[e + 0] = enemies[e + 1];
			enemies[e + 1] = tempStoreDistance;
			
			// sort enemy index
			var tempStoreEnemy : int = enemy[e];
			enemy[e + 0] = enemy[e + 1];
			enemy[e + 1] = tempStoreEnemy;
			
			e = -1;
		}
	}
}

function DebugEnemyDistances()
{
	for ( var e : int = 0; e < enemy.Length; e ++ )
	{
		Debug.Log( "enemy[" + enemy[e] + "] has a distance of " + enemies[e] );
	}
}