only sorting if stocks are not null