;sort strings to alphabetic 

		include	"baselibs.i"
		include	"baselibs1.i"
		include	"string.i

	


		#define	MOUNT,10		;the mount of the arrays
		#define	LINE_LENGTH,40
		#define	OLD_MODE,1005
		variables

		CPTR	_string			;address of string
		CPTR	_letters			;address of letters
		array	char,string,MOUNT,LINE_LENGTH
		array	char,letters,MOUNT,LINE_LENGTH

	

	main()

	int	size,address,limit
	int	count,count1,count2,flag
	CPTR	conhandle
	{
;addresses of the textfiles to pointers


;get lines for sorting
		func	conhandle,=,fopen,<"CON:0/100/640/150/**CLI_WINDOW**">,OLD_MODE
		if	conhandle,==,0,1
			{
			print	<"no open con:">
			exit	0
			}
			ifend	1
		calc	_stdout,=,conhandle

		calc	count,=,0
		while	count,!=,MOUNT,1
			{
			print	<"give a line ">
			pointer	>string,=&,string,count,0
			func	size,=,gets,_string		;don't give more than 39 characters
			calc	count,++
			}	1

;sort lines

		calc	flag,=,1
		calc	limit,=,MOUNT,-,1
		while	flag,==,1,2			;sort until flag is clear
			{	
			calc	count1,=,0
			calc	count2,=,1
			calc	flag,=,0		;clear flag before sorting
		
				while	count1,!=,limit,21	;check all lines
					{

					pointer	_string,=&,string,count1,0	
					pointer	_letters,=&,string,count2,0

					if	strcmp,_string,_letters,»,0,4		;check bigger one
						{
						strswap	_string,_letters		;swap lines, if the first is bigger

						calc	flag,=,1				; set flag all is not ready
						}	
						ifend	4

						calc	count1,++				;next line
						calc	count2,++
				}	21
			calc	limit,--
			}	2

;print how many checking need sorting

;print sorting lines in order

		print	<"sorting lines  ">

		calc	count,=,0
		while	count,!=,MOUNT,3
			{
			pointer	_string,=&,string,count,0		;the addres of the line
			print	_string
			print	<"  ">
			calc	count,++
			}	3	

	getchar()
	fclose	conhandle
	}
	end

