FactSet Interview Question

How to sort data wide to long and long to wide? (R & Python)