add sorting functionality to code samples