This is a comment/answer to the comments of Peter Grill's original answer (+1).
The \List macro takes one optional argument, the style that should be used if none is specified (i.e. …,<entry>,…).
I also took the liberty to use the node distance key instead of the hard-coded (0.5*\i cm,0) placement.
Code
\documentclass{article}
\usepackage{tikz}
\usepackage{xstring}
\tikzset{
raw sort entry/.style={rectangle, thick, draw, node distance=1.5em},
sort entry black/.style={raw sort entry, black, fill=white},
sort entry blackgray/.style={raw sort entry, black, fill=gray!25},
s1/.style={raw sort entry, red, fill=yellow!30},
s2/.style={raw sort entry, blue, fill=green!20},
s3/.style={raw sort entry, violet, fill=orange!25}
}
\newcommand*{\List}[2][sort entry black]{%
\par\noindent%
\edef\listtoprocess{#2}%
\def\ListToProcess{}%
\begin{tikzpicture}[inner sep=2pt, outer sep=0]
\foreach \content in \listtoprocess{
\IfSubStr{\content}{/}{% true
\xdef\ListToProcess{\ListToProcess,\content}
}{% false
\xdef\ListToProcess{\ListToProcess,#1/\content}
}
}
\StrGobbleLeft{\ListToProcess}{1}[\ListToProcess]% removes the first comma (\listToProcess is empty at the start)
\foreach [count=\i] \Style/\Value in \ListToProcess {
\ifnum\i=1\relax
\node [raw sort entry, \Style] (sortnode\i) {\Value};
\else
\node [raw sort entry, right of=sortnode\number\numexpr\i-1\relax, \Style] (sortnode\i) {\Value};
\fi
}
\end{tikzpicture}%
}
\begin{document}
\List{s1/1, 2, s3/3}
\List[sort entry blackgray]{s2/1, s1/2, s1/3, 1, s2/2, s3/3, s2/2, s2/3}
\List[s1]{1,2,/3,/2,3}% /3 and /2 falls back to no explicit \Style, so the resulting style is that from the \node [raw sort entry, …]
\end{document}
Output

\foreachwill use the last value if one is not provided. – Peter Grill Nov 21 '12 at 23:26\tikzset{styledefault/.style={thick, draw=black,fill=white}}) and providestyledefaultbefore\Style(i.e.\node […, styledefault, \Style] …) and use it as\List{style1/1, /2, style3/3}. A more sophisticated solution would be to check#1for entries without/and prependstyledefault/so one can use\List{style1/1, 2, style3/3}.xstringwill be helpful. – Qrrbrbirlbel Nov 22 '12 at 06:23\edefin case the parameter is defined in a macro. Added comment in code -- was looking for the related question but have not been able to find it. – Peter Grill Nov 22 '12 at 06:45\edefsolution. I think that solution should be posted there though. You can do it if you want? – Peter Grill Nov 22 '12 at 07:23