I need to sort the values according to the following problem:
For every n, determine the triples (i,j,k) that satisfies i+j+k=n, then sort the triples (for every n) with respect to the value of the formula (4*i+5*j+4*k+1) in ascending order. Here is the rough pseudocode:
for n in range(3,N+1):
for i in range(1,n-1):
for j in range(1,n-1):
for k in range(1,n-1):
if(i+j+k)==n:
[sort triples in ascending order wrt to the value of (4*i+5*j+4*k+1)]
For now, I can only print the triples that satisfy i+j+k=n.
Is there a way to do the sorting inside the n loop? Or should I store them in an array then bubble sort later?