Use theme_item_list function for it, see the below code
$title = 'Title';
$type = 'ol';
$items = array(
'one',
'two',
'three',
'four',
'five',
);
$items[] = array(
'data' => 'something',
'class' => array('dummy'=>'category'),
'children' => array('1.1','1.2',array('data'=>'1.3','class' => array('dummy'=>'category'),'children'=>array('1.3.1','1.3.2')))
);
$attributes = array('class' => array('test-class', 'demo-class'));
print theme_item_list(array(
'items' => $items,
'title' => $title,
'type' => $type,
'attributes' => $attributes
));
This will give you following HTML output:
<div class="item-list"><h3>Title</h3>
<ol class="test-class demo-class">
<li class="first">one</li>
<li>two</li>
<li>three</li>
<li>four</li>
<li>five</li>
<li class="category last">something
<div class="item-list">
<ol class="category">
<li class="first">1.1</li>
<li>1.2</li>
<li class="category last">1.3
<div class="item-list">
<ol class="category">
<li class="first">1.3.1</li>
<li class="last">1.3.2</li>
</ol>
</div>
</li>
</ol>
</div>
</li>
</ol>
</div>