EDIT: By using @David C. Ullrich idea, the proof can be greatly simplified (credit goes to his deleted post):
Let $M=\max_{k \in 1:n}\left|\frac{a_k}{b_k}-c\right|$ it follows that:
$|a_i-cb_i|\le Mb_i$ for all $i=1,2,\ldots,n$
$|a_1+\ldots+a_n -c(b_1+\ldots+b_n)|\le|a_1-cb_1|+\ldots+|a_n-cb_n|\le M(b_1+\ldots+b_n)$
And one gets the desired result by dividing both sides by $b_1+\ldots+b_n$
INITIAL ANSWER:
To prove the last inequality,drop first the absolute value, as you deal with positive numbers. Then, without loss of generality, reorder the indices such that $\frac{a_1}{b_1}\le\frac{a_2}{b_2}\le\ldots\le\frac{a_n}{b_n}$ and proceed by induction.
The second step is to observe that you can drop the requirement $a_i\ge 0$, as we always have $\frac{|a_1+\ldots+a_n|}{b_1+\ldots+b_n}\le\frac{|a_1|+\ldots+|a_n|}{b_1+\ldots+b_n}\le\max_{k \in 1:n}\frac{|a_k|}{b_k}$
As the last step, you may apply the last inequality for $a_1\leftarrow a_1-cb_1, \ldots a_n\leftarrow a_n-cb_n$ to get your desired result.
Thanks to Kavi Rama Murthy, I understand how to deduce the Cauchy–Schwarz inequality !
Let $c_k = a_k/\sqrt{\sum|a_i|^2}$ and $d_k = b_k/\sqrt{\sum|b_i|^2}$
So we have: $$\sum_{k=1}^{n}|c_kd_k|\le\frac{1}{2}\left(\sum_{k=1}^{n}c_k^2+\sum_{k=1}^{n}d_k^2\right)$$
$$\left|\sum_{k=1}^{n}c_kd_k\right|\le\sum_{k=1}^{n}|c_kd_k|\le\frac{1}{2}\left(\sum_{k=1}^{n}c_k^2+\sum_{k=1}^{n}d_k^2\right)$$
$$\left|\sum_{k=1}^{n}c_kd_k\right|\le\frac{1}{2}\left(\sum_{k=1}^{n}c_k^2+\sum_{k=1}^{n}d_k^2\right)$$
$$\left|\sum_{k=1}^{n}c_kd_k\right|^2\le\left(\frac{1}{2}\left(\sum_{k=1}^{n}c_k^2+\sum_{k=1}^{n}d_k^2\right)\right)^2$$
$$\left(\sum_{k=1}^{n}c_kd_k\right)^2\le\left(\frac{1}{2}\left(\sum_{k=1}^{n}c_k^2+\sum_{k=1}^{n}d_k^2\right)\right)^2$$
$$2\left(\sum_{k=1}^{n}c_kd_k\right)^2\le\frac{1}{2}\left(\sum_{k=1}^{n}c_k^2\right)^2+\frac{1}{2}\left(\sum_{k=1}^{n}d_k^2\right)^2+\left(\sum_{k=1}^{n}c_k^2\right)\left(\sum_{k=1}^{n}d_k^2\right)$$
$$2\left(\sum_{k=1}^{n}\frac{a_kb_k}{\sqrt{\sum|a_i|^2\times\sum|b_i|^2}}\right)^2\le\frac{1}{2}\left(\sum_{k=1}^{n}\frac{a_k^2}{\sum|a_i|^2}\right)^2+\frac{1}{2}\left(\sum_{k=1}^{n}\frac{b_k^2}{\sum|b_i|^2}\right)^2+\left(\sum_{k=1}^{n}\frac{a_k^2}{\sum|a_i|^2}\right)\left(\sum_{k=1}^{n}\frac{b_k^2}{\sum|b_i|^2}\right)$$
$$\frac{2}{\sum|a_i|^2\times\sum|b_i|^2}\left(\sum_{k=1}^{n}a_kb_k\right)^2\le\frac{1}{2(\sum|a_i|^2)^2}\left(\sum_{k=1}^{n}a_k^2\right)^2+\frac{1}{2(\sum|b_i|^2)^2}\left(\sum_{k=1}^{n}b_k^2\right)^2+\frac{1}{\sum|a_i|^2\times\sum|b_i|^2}\left(\sum_{k=1}^{n}a_k^2\right)\left(\sum_{k=1}^{n}b_k^2\right)$$
$$\frac{2}{\sum|a_i|^2\times\sum|b_i|^2}\left(\sum_{k=1}^{n}a_kb_k\right)^2\le2$$
$$\left(\sum_{k=1}^{n}a_kb_k\right)^2\le\sum|a_i|^2\times\sum|b_i|^2$$$$\left(\sum_{k=1}^{n}a_kb_k\right)^2\le\sum a_k^2\times\sum b_k^2$$
Best Answer
The second inequality results from multiple applications of the rearrangement inequality, which gives us $$ a_1b_k+a_2b_{k+1}+\cdots+a_{n-k+1}b_n+a_{n-k+2}b_1+\cdots+a_nb_{k-1}\leq a_1b_1+a_2b_2+\cdots+a_nb_n $$ for all $2\leq k\leq n$.