rewrote get_ordered_values function to work with differences
rewrote get_ordered_values function to work with differences