Pergunta de entrevista da empresa Lucid Software

first, two questions are related to sorting and string manipulation