#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <limits.h>
#include <assert.h>

#define foreach(item, array) \
    for(int keep = 1, \
            count = 0,\
            size = sizeof (array) / sizeof *(array); \
        keep && count != size; \
        keep = !keep, count++) \
      for(item = (array) + count; keep; keep = !keep)

//prototypes
void readFile(FILE *in, int *arr);
int *sortArrayBubble(int *arr);
int *sortArrayInsert(int *arr);
void printArray(int *arr);
int getListSize(int *arr);

int arr[100000];

int main(int argc, char* argv[])
{
	FILE *in = stdin;
   	char* in;

   	if(argc > 2)
   	{
      		fprintf(stderr, "Usage: %s [<file>]\n", argv[0]);
     	 	exit(EXIT_FAILURE);
   	}
   	if(argc == 2)
   	{
      		in = fopen(argv[1], "r");
      		if(!in)
      		{
        		perror(argv[0]);
        	 	exit(EXIT_FAILURE);
      		}
	}
	int bubble[getListSize()];
	readFile(in,*bubble);
	sortArrayBubble(*bubble);
	printArray();
	return 0;
}

void readFile(FILE *in, int* arr)
{
	int i = 0;
	while(!feof(in))
	{
		fscanf(in, "%d",&arr[i]) ;
		i++;
	}
}


void sortArrayBubble()
{
	bool swapped = true;
	int temp;
	int i = 0;
	int arrsize = sizeof(arr)/sizeof(int);
	while(swapped)
	{
		swapped = false;
		for(i; i < arrsize-1; i++)
		{
			if(arr[i]>arr[i+1])
			{
				temp = arr[i];
				arr[i] = arr[i+1];
				arr[i+1] = temp;
				swapped = true;
			}
		}
		i = 0;
	}
}

void sortArrayInsert()
{
	int out[100000];
	int i = 0;
	int o = 0;
	for(i; i < 100000; i++)
	{
		
	}
}

void printArray()
{
	foreach(int *v, arr) {
   		 printf("%d\n", *v);
	}
}

int getListSize(FILE *in)
{
	int i = 0;
	while(!feof(in))
	{
		i++;
	}
	return i;
}
