sort_c() and neighbourhood functions added