<p>Is there any tools or commands to sort bed format file? The correct order is chr1, chr2, chr3, chr4,..., chr22, chrX, chrY.</p>

GNU sort can now sort in alpha-numeric order. See option `-V, --version-sort` of the following version "sort (GNU coreutils) 8.17".

Here is an example:

    $ echo -e "chr10\t1\t2\tA\nchr2\t1\t2\tB\nchr1\t1\t2\tC"
    chr10   1       2       A
    chr2    1       2       B
    chr1    1       2       C

And the result is:

    $ echo -e "chr10\t1\t2\tA\nchr2\t1\t2\tB\nchr1\t1\t2\tC" | sort -k1,1V
    chr1    1       2       C
    chr2    1       2       B
    chr10   1       2       A