Calculate gravity on a 1D field
Haskell, 169 180 bytes



g s=sum[n|c&lt;-s,(d,n)&lt;-zip"SD LN"[-2..],c==d]
w=elem ' '
h(x:y:r)|(w x&amp;&amp;g y&lt;0)||(w y&amp;&amp;g x&gt;0)=y:h(x:r)|w(x++y)||g x&lt;0=x:h(y:r)|t&lt;-x++y=h$t:r
h r=r
concat.until((==)=&lt;&lt;h)h.map(:[])


Try it online!
 Example usage: concat.until((==)=&lt;&lt;h)h.map(:[]) $ " SDLN ".

Edit: +11 bytes, now also works for the "  NSDLLD  " test case proposed by @zgrep.

(short) Explanation:

h works on a list of tokens where initially each char of the input string is token. Until the token list no longer changes, h bubbles through the list comparing two tokens x and y at a time. Depending on the tokens their order is kept (x:h(y:r)), they are swapped (y:h(x:r)) or combined to a single token (t&lt;-x++y=h$t:r).

g computes the weight of a token and w checks whether a token contains a space.