From: Axel Kohlmeyer (
Date: Mon Nov 16 2020 - 07:47:14 CST

On Mon, Nov 16, 2020 at 6:54 AM Prathit Chatterjee <> wrote:

> Dear VMD/TCL experts,
> Kindly let me know how to sort the following list
> "GLU_43 GLY_8 VAL_11 ILE_13 TYR_15 LYS_16 VAL_18 LYS_36 ASP_19 LEU_20
> SER_21 LYS_22 VAL_23 SER_25 LYS_26 GLY_7 CYS_27 VAL_14 GLY_28 THR_24 SER_29
> LEU_30 GLY_31 GLY_9 ASN_32 GLN_12 ILE_33 HIE_34 HIE_35 PRO_37 GLY_38 GLY_39
> PRO_17 GLY_40 GLN_41 VAL_42 PRO_6 LYS_10"
> as an increasing function of the integers in the corresponding suffices as
> given below:
> PRO_6 GLY_7 GLY_8 GLY_9 LYS_10 VAL_11 GLN_12 ILE_13 VAL_14 TYR_15 LYS_16
> PRO_17 VAL_18 ASP_19 LEU_20 SER_21 LYS_22 VAL_23 THR_24 SER_25 LYS_26
> CYS_27 GLY_28 SER_29 LEU_30 GLY_31 ASN_32 ILE_33 HIE_34 HIE_35 LYS_36
> PRO_37 GLY_38 GLY_39 GLY_40 GLN_41 VAL_42 GLU_43
> I tried different options related to the "*lsort*" command, but could not
> resolve the issue.
I am not aware of any list sorting implementation that can do a sort based
on numerical value with an offset into a string.
Thus what you need to do is to first transform your list into something
that can be sorted, e.g. split each string into a sublist (GLU_43 -> {"GLU"
"43"}) and then you can use the -index option to test lsort to sort by the
index into the sublist. you may also want to use the -integer option to
sort by numerical value and not string value.


> Any suggestions will be deeply appreciated.
> Thanks in advance,
> Prathit

Dr. Axel Kohlmeyer
College of Science & Technology, Temple University, Philadelphia PA, USA
International Centre for Theoretical Physics, Trieste. Italy.