J
James P
Hi All,
I have an xml file as listed below. This is a list of scripts. Some of the
scripts depend on the output of other scripts. I want to sort this xml in
such a way that the scripts are listed in the correct order of execution. I
created an IComparer class and implememted the Compare method. I am calling
Array.Sort on an XmlNode array. The sorting is not correct. Can anyone
suggest a correct algorithm for a compare method to sort this XML?
Thanks.
James
<root>
<scripts>
<script>
<name>script0</name>
<sequence>0</sequence>
<references>script6|script14|script20|script4|script24|script16|script9|scri
pt22|script25</references>
</script>
<script>
<name>script1</name>
<sequence>1</sequence>
<references>script0|script6|script14|script9|script25|script15</references>
</script>
<script>
<name>script2</name>
<sequence>2</sequence>
<references>script10|script6</references>
</script>
<script>
<name>script3</name>
<sequence>3</sequence>
<references>script0|script6</references>
</script>
<script>
<name>script4</name>
<sequence>4</sequence>
<references>script6|script20</references>
</script>
<script>
<name>script5</name>
<sequence>5</sequence>
<references>script6</references>
</script>
<script>
<name>script6</name>
<sequence>6</sequence>
<references>
</references>
</script>
<script>
<name>script7</name>
<sequence>7</sequence>
<references>script10|script6|script14</references>
</script>
<script>
<name>script8</name>
<sequence>8</sequence>
<references>script10|script6|script14</references>
</script>
<script>
<name>script9</name>
<sequence>9</sequence>
<references>script7|script8|script10|script11|script2</references>
</script>
<script>
<name>script10</name>
<sequence>10</sequence>
<references>
</references>
</script>
<script>
<name>script11</name>
<sequence>11</sequence>
<references>script14|script6|script2|script10</references>
</script>
<script>
<name>script12</name>
<sequence>12</sequence>
<references>script6|script0</references>
</script>
<script>
<name>script13</name>
<sequence>13</sequence>
<references>script14|script6</references>
</script>
<script>
<name>script14</name>
<sequence>14</sequence>
<references>script6</references>
</script>
<script>
<name>script15</name>
<sequence>15</sequence>
<references>
</references>
</script>
<script>
<name>script16</name>
<sequence>16</sequence>
<references>script6|script20</references>
</script>
<script>
<name>script17</name>
<sequence>17</sequence>
<references>script6|script18</references>
</script>
<script>
<name>script18</name>
<sequence>18</sequence>
<references>script6|script25</references>
</script>
<script>
<name>script19</name>
<sequence>19</sequence>
<references>script6</references>
</script>
<script>
<name>script20</name>
<sequence>20</sequence>
<references>script6|script15</references>
</script>
<script>
<name>script21</name>
<sequence>21</sequence>
<references>script6|script24|script0|script20</references>
</script>
<script>
<name>script22</name>
<sequence>22</sequence>
<references>script6|script15|script24|script20</references>
</script>
<script>
<name>script23</name>
<sequence>23</sequence>
<references>
</references>
</script>
<script>
<name>script24</name>
<sequence>24</sequence>
<references>script6|script25</references>
</script>
<script>
<name>script25</name>
<sequence>25</sequence>
<references>script6</references>
</script>
<script>
<name>script25</name>
<sequence>26</sequence>
<references>script0|script2|script4|script7|script8|script9|script10|script1
1|script14|script19|script18|script20|script24|script25|script16|script5|scr
ipt22|script15|script6|script1</references>
</script>
</scripts>
</root>
I have an xml file as listed below. This is a list of scripts. Some of the
scripts depend on the output of other scripts. I want to sort this xml in
such a way that the scripts are listed in the correct order of execution. I
created an IComparer class and implememted the Compare method. I am calling
Array.Sort on an XmlNode array. The sorting is not correct. Can anyone
suggest a correct algorithm for a compare method to sort this XML?
Thanks.
James
<root>
<scripts>
<script>
<name>script0</name>
<sequence>0</sequence>
<references>script6|script14|script20|script4|script24|script16|script9|scri
pt22|script25</references>
</script>
<script>
<name>script1</name>
<sequence>1</sequence>
<references>script0|script6|script14|script9|script25|script15</references>
</script>
<script>
<name>script2</name>
<sequence>2</sequence>
<references>script10|script6</references>
</script>
<script>
<name>script3</name>
<sequence>3</sequence>
<references>script0|script6</references>
</script>
<script>
<name>script4</name>
<sequence>4</sequence>
<references>script6|script20</references>
</script>
<script>
<name>script5</name>
<sequence>5</sequence>
<references>script6</references>
</script>
<script>
<name>script6</name>
<sequence>6</sequence>
<references>
</references>
</script>
<script>
<name>script7</name>
<sequence>7</sequence>
<references>script10|script6|script14</references>
</script>
<script>
<name>script8</name>
<sequence>8</sequence>
<references>script10|script6|script14</references>
</script>
<script>
<name>script9</name>
<sequence>9</sequence>
<references>script7|script8|script10|script11|script2</references>
</script>
<script>
<name>script10</name>
<sequence>10</sequence>
<references>
</references>
</script>
<script>
<name>script11</name>
<sequence>11</sequence>
<references>script14|script6|script2|script10</references>
</script>
<script>
<name>script12</name>
<sequence>12</sequence>
<references>script6|script0</references>
</script>
<script>
<name>script13</name>
<sequence>13</sequence>
<references>script14|script6</references>
</script>
<script>
<name>script14</name>
<sequence>14</sequence>
<references>script6</references>
</script>
<script>
<name>script15</name>
<sequence>15</sequence>
<references>
</references>
</script>
<script>
<name>script16</name>
<sequence>16</sequence>
<references>script6|script20</references>
</script>
<script>
<name>script17</name>
<sequence>17</sequence>
<references>script6|script18</references>
</script>
<script>
<name>script18</name>
<sequence>18</sequence>
<references>script6|script25</references>
</script>
<script>
<name>script19</name>
<sequence>19</sequence>
<references>script6</references>
</script>
<script>
<name>script20</name>
<sequence>20</sequence>
<references>script6|script15</references>
</script>
<script>
<name>script21</name>
<sequence>21</sequence>
<references>script6|script24|script0|script20</references>
</script>
<script>
<name>script22</name>
<sequence>22</sequence>
<references>script6|script15|script24|script20</references>
</script>
<script>
<name>script23</name>
<sequence>23</sequence>
<references>
</references>
</script>
<script>
<name>script24</name>
<sequence>24</sequence>
<references>script6|script25</references>
</script>
<script>
<name>script25</name>
<sequence>25</sequence>
<references>script6</references>
</script>
<script>
<name>script25</name>
<sequence>26</sequence>
<references>script0|script2|script4|script7|script8|script9|script10|script1
1|script14|script19|script18|script20|script24|script25|script16|script5|scr
ipt22|script15|script6|script1</references>
</script>
</scripts>
</root>