public static void main(String[] args)
	{
		ArrayList<Product> products = new ArrayList<>();
		
		try {
			BufferedReader fileReader = new BufferedReader(new FileReader("D:\\Soft\\JAVA\\LoopsMethodsClasses\\src\\ListInput.txt"));;
			File fileProducts = new File("D:\\Soft\\JAVA\\LoopsMethodsClasses\\src\\ListOutput.txt");
			fileProducts.createNewFile();
			BufferedWriter fileWriter = new BufferedWriter(new FileWriter("D:\\Soft\\JAVA\\LoopsMethodsClasses\\src\\ListOutput.txt"));
			
			while(true){
				String line = fileReader.readLine();
				if(line == null){
					fileReader.close();
					break;
				}
				
				String[] input = line.split(" ");
				products.add(new Product(input[0], new BigDecimal(input[1])));
			}
			
			Collections.sort(products);
			
			for (Product product : products){
				System.out.println(product.getPrice() + " " + product.getName());
				fileWriter.write(product.getPrice() + " " + product.getName());
				fileWriter.newLine();
			}
			
			fileWriter.close();
		} catch (IOException e){
			System.out.println("Error");
		}
	}