Let x be the number of pounds of peanuts and y be the number of pounds of cashews he sold.

From the question we can mount two equations:

2.80x + 4.30y = 158.5 (the amount of pounds of each, times each price and summed up totals 158.5)

x + y = 40 (he sold a total of 40 pounds)

From the second equation we can write x = 40 - y, and plugging this into the first equation we obtain

2.80 * (40 - y) + 4.30y = 158.5

112 - 2.80y + 4.30y = 158.5

1.5y = 46.5

y = 46.5/1.5 = 31

And as x = 40 - y, we obtain x = 40 - 31 = 9.

Thus, he sold 9 pounds of peanuts and 31 pounds of cashews.