How do I sort a class array in C++? The array has stock info. I need to sort based on sector. (stocks.getStockSector()). Check first "answer" for more info...

1

1 Answers

Love and Harmony Profile

Continuation of Question...

Basically, there is an array called Stock stocks[maxSize]; Each line of the array contains the trading symbol, company name, stock sector, number of shares, purchase price, and current price. I need a function that sorts the array of passed Stock objects according to increasing sector value.

The sectors, which are of enumerated data type, are:

enum Sector {TECHNOLOGY = 10, HEALTH = 20, FINANCIAL = 30, CONSUMER_GOODS = 40, UTILITIES = 50};

Answer Question

Anonymous