No, It won't work.
The picture in the iFixit's SSD replacement guide of iMac 27 late 2013 shows the connector of iMac 27 2012 model: 8+18 pins
(http://macbidouille.com/articles/488/page5)
White iMac late 2013, (21.5", 27" and 27" 5K) the connector has changed: 12+16 pins
(http://macbidouille.com/news/2013/06/11/macbook-air-2013-le-ssd-et-son-connecteur)