[postgis-users] Sorting/ordering linestrings

Stephen Woodbridge woodbri at swoodbridge.com
Wed Mar 30 16:47:43 PDT 2011

Charles Galpin<cgalpin<at>  lhsw.com>  writes:

> Does anyone have any bright ideas on how to sort linestrings (with postgis
> or  anything else for that matter).

ok, need some more criteria here. Sorting linestrings is a proposed 
solution to an undisclosed problem. What is your problem?

If you have not additional criteria, then:

select *
  from my_table
  order by st_x(st_startpoint(the_geom)), st_y(st_startpoint(the_geom));

or maybe just:

select *
  from my_table
  order by the_geom::text;


More information about the postgis-users mailing list