updated example to include sorting and range