|
The Yanaconda language does not contain a single function to sort a list, since most of the time one wants to sort something else based on the numbers stored in a list.
The following example assumes that the simulation cell contains one protein multiple times in
different, non-overlapping conformations
. This macro sorts these conformations based on their energy (the cell is assumed to be the last object):
energylist() = EnergyObj all
do
sorted=1
for i=1 to Objects-2
if energylist(i)>energylist(i+1)
SwapObj (i),(i+1)
swap=energylist(i)
energylist(i)=energylist(i+1)
energylist(i+1)=swap
sorted=0
while not sorted
|