Sort-a-number. Sorta Inspired by the ill-fated sorting-a-numbers-digits-without-using-an-array, but I thought it made a better code golf than SO question.

Given a positive integer, sort the digits in that integer.

Lowest score wins!


Start with 0 points.
Add one point per character.
Add 20 points for each array you use.
Add 10 points for each multi-character string in your code. (Except the initial input as long as it is converted to an integer without any other operations done on it.)
Add 32 points if the maximum number of digits your program can handle is limited by your program (as opposed to the machine).
Subtract 10 points if your code can change the direction of the sort given another argument (whatever you want, but for example 0 for descending sort and 1 for ascending.)


Every language is different, but the idea is to avoid any kind of iterable-of-digits hackery.

Example:

Input: 52146729

Output: 97654221 or 12245679

Notes:


Use any built-in sorting capabilities your programming language provides, but if that sort feature involves strings or arrays, take the penalty!
You can write the solution as a function that takes an integer directly, or as a program that takes an argument from argv, a file or stream and converts it to an integer. As long as you convert it to an integer immediately and discard the original char* input without doing any further operations on it, no penalty applies.
The penalties apply not only to string literals in your program text, but any part of your program feature that arguably inputs or outputs a string or iterable. For example, JavaScript String.prototype.split has at least one string as input (this) and an Array as output, so +30 for using that.
I've tried to make these rules guide the principle of the algorithm design, not the initial/final I/O (hence note #2). I don't think the penalty ought to apply to int(input()) even if input's signature says it returns a string, as long as that expression is the initial entry point of the program. Likewise, if the final output of the program is print(x) and x must be a string, the penalty doesn't apply to the last-ditch string casting operation. All that said, I explicitly never said that this had to be a program or where the I/O had to come from or go. A function that takes an int and returns an int would serve, and wouldn't suffer from these ambiguities.
Haskell 106

t=10;d=divMod;s z|z&lt;w z=s$w z|t&gt;0=z
w x|x&lt;t=x|y&gt;z=(q*t+y)*t+z|t&gt;0=y+t*(w v)where{(v,y)=d x t;(q,z)=d v t}


example:

ghci&gt; s 502010406072952146729521467295214672952146729
999997777766666555554444422222222221111100000


An answer that doesn't dodge the question.

An explanation was requested, here it is ungolfed. It's a very inefficient bubble sort.

-- t=10 - alias for 10. d=divMod - alias for divMod.
-- The alias for '10' turns out to be unnecessary; inlining it
-- and using '1&gt;0' for True has the same character count. It's
-- a relic of earlier versions of the code.

-- 's': if no digits need swapped, return the number,
-- otherwise return 's' applied to the number with
-- that pair of digits swapped.
sort z=
  let temp=sort_pair z
  -- because we are sorting in descending order,
  -- sorting a pair of digits always increases the number.
  -- testing &gt; costs one less char than ==.
  if z&lt;temp then
    -- golfed version uses guards instead of if/else to save space.
    -- t&gt;0 is '10 &gt; 0', which is 'True', in fewer chars.
    sort temp
  else
    z
-- 'w': recursively swap one pair of out of order digits, or
-- return the original number if no pairs needed swapped.
sort_pair x=
  -- haskell does the assignments below lazily, they aren't
  -- calculated unless I use them. 'divMod' lets me do this
  -- with fewer chars.
  let y = x `mod` 10 -- last digit
      v = x `div` 10 -- all but last digit
      z = v `mod` 10 -- second last digit
      q = v `div` 10 -- all but last 2 digits
  in
  if x &lt; 10 then
    x
  else if y &gt; z then
    -- last 2 digits are out of order. swap them &amp; return
    -- This is rearranged using Horner's method to save space
    -- http://en.wikipedia.org/wiki/Horner%27s_method
    -- ... although it turns out not to save anything, it's a relic.
    (q * 10 + y)*10 + z
  else
    -- last digit is ok, so try sort_pair on remaining digits
    let temp = sort_pair v in
    -- put last digit back on the end and return
    -- having the bracketed expression last here
    -- let me remove a space before 'where'
    y+(10*temp)


Shorter answers exist in Haskell, equivalent to some of the others posted, eg:

import Data.List;s=read.sort.show::Integer-&gt;Integer


... scores 52+20=72, or this, scoring 45+20=65:

import Data.List;main=interact(reverse.sort)


... but the spirit of the question - no arrays, strings, or characters - is more interesting.